/*==============================================================================
This do file serves to replicate all regression tables in the paper (Table 1-8, Appendix Table A1-A44), except: 
	Tables replicated by R: # Table 1, 2, A1, A2, A5, A6, A39, A40. 
	Tables which don't need code to generate: # Table A7, A8, A16, A17, A44
===============================================================================*/

* need to change for replication
global USER "~/Replication"
global path = "$USER/Replication_final" 

**** path ****
global data="$path/Data"
global survey_dir = "$data/survey data used for analysis"
global zero2ipo_dir = "$data/Zero2IPO data used for analysis"
global survey2021_dir = "$data/2021 survey data analysis on pros and cons"
global save_dir = "$path/Output" 
global maintable_dir="$save_dir/main table" 
global appendixtable_dir="$save_dir/appendix table" 
set matsize 1000


/*******************************************************************************
**********************         Main Results         ****************************
*******************************************************************************/

/*==============================================================================
Table 1: Summary Statistics
	see R code in the folder 
===============================================================================*/


/*==============================================================================
Table 2: Government Ownership of Investors and Fund Managers
	see R code in the folder 
===============================================================================*/

/*==============================================================================
Table 3. Government-Owned GPs Perform Worse
===============================================================================*/
* import gp performance data
use "$zero2ipo_dir/GP_performance_details.dta", clear
	keep GP_fullname gp* assort_sample
	ren *, lower
	tempfile performance
	save `performance', replace
	
* import modified gp headquarter data
use "$zero2ipo_dir/ActiveOwnershipGP_2015-19_SummaryStats.dta", clear
	keep gp_fullname hq_province_group
	tempfile hqnew
	save `hqnew', replace
	
***** gp regression ****
* import gp ownership data
use "$zero2ipo_dir/gp_ownershipsample_info.dta", clear
		**** keep if assort_sample == 1
		merge 1:1 gp_fullname using `hqnew', nogen keep(3)
		
        **** gen hq fe for regressions (missing gp_hq_province_group are not included) ***
        encode hq_province_group, gen(gphq)
		label var gphq "GP HQ fixed effects"
		
        **** gov GP (missing gp_total_gov_share means no gov shares, 0 means gov shares but percentages are missing) ****
        gen gpgov_relate = (gp_total_gov_share >=0 & !missing(gp_total_gov_share))  	
        label var gpgov_relate "Gov GPs"
		drop gp_rank_comprehensivereturn gp_irr 
		merge 1:1 gp_fullname using `performance', nogen keep(3)
		
**** link sample ****
       **** gov GP (missing gp_total_gov_share means no gov shares, 0 means gov shares but percentages are missing) ****
        replace gpgov_relate = (gp_total_gov_share >=0 & !missing(gp_total_gov_share ))  	
       
local model_num = 0
label var gp_rank_fundraisingusd "Fund Raising Amount"
egen min_gp_comprehensive_return = min(gp_comprehensive_return)
egen max_gp_comprehensive_return = max(gp_comprehensive_return)
gen gp_comprehensive_return_std = (gp_comprehensive_return - min_gp_comprehensive_return)/(max_gp_comprehensive_return - min_gp_comprehensive_return)

winsor gp_irr, gen(W_gp_irr) p(0.05) highonly
winsor gp_rank_aumusd, gen(W_gp_rank_aumusd) p(0.05) highonly

label var W_gp_rank_aumusd "AUM"

foreach var in gp_comprehensive_return_std  W_gp_irr {
        local model_num = `model_num' + 1
        eststo col1_`model_num': qui reg `var' gpgov_relate, robust
                estadd local hq_fe "No"
               
        eststo col2_`model_num': qui reg `var' gpgov_relate i.gphq, robust
                estadd local hq_fe "Yes"
				
		eststo col3_`model_num': qui reg `var' gpgov_relate W_gp_rank_aumusd, robust
                estadd local hq_fe "No"
		
		eststo col4_`model_num': qui reg `var' gpgov_relate W_gp_rank_aumusd i.gphq, robust
				estadd local hq_fe "Yes"
}
	
esttab col1_1 col2_1 col3_1 col4_1 col1_2 col2_2 col3_2 col4_2 using "$maintable_dir/Table3.tex", label booktabs eqlabels(none) replace ///
	star(* 0.1 ** 0.05 *** 0.01) t(%6.2f) b(%8.3f)  ///
        stats(N r2 hq_fe ,labels("Observations" "R-Squared"  "HQ FEs" ) fmt(a3 %8.3f a3)) ///
	mtitle("CR" "CR" "CR" "CR" "IRR" "IRR" "IRR" "IRR") title("Govnment-Owned GPs Perform Worse") ///
	drop(*gphq _cons) 
	
eststo clear	


/*==============================================================================
Table 4. Assortative Matching Between Government-Owned GPs and LPs
===============================================================================*/
* import gp performance data
use "$zero2ipo_dir/GP_performance_details.dta", clear
ren *, lower
replace gp_irr = gp_irr_1090 
keep gp_fullname gp_exit_invest gp_irr gp_comprehensive_return
*merge 1:1 gp_fullname using `cr2win', nogen keep(3)
	tempfile cr2win
	save `cr2win', replace

***** link perform data to assortative matching sample ****
use "$zero2ipo_dir/assortativematching_newactivesample.dta", clear
        duplicates drop // unique GP-LP pairs
		
		merge m:1 gp_fullname using `cr2win', nogen keep(3)
		egen min_gp_comprehensive_return = min(gp_comprehensive_return)
		egen max_gp_comprehensive_return = max(gp_comprehensive_return)
		gen gp_comprehensive_return_std = (gp_comprehensive_return - min_gp_comprehensive_return)/(max_gp_comprehensive_return - min_gp_comprehensive_return)
		
		qui sum gp_exit_invest, de
		global gp_exit_invest_med = `r(p50)'
		qui sum gp_comprehensive_return_std, de
		global gp_cr_med = `r(p50)'
		qui sum gp_irr, de
		global gp_irr_med = `r(p50)'
		
****** the next main step: gen quality/gov measure for GP & gov measure for LP *********
****** generate gov LP, gov GP and high quality GP ****
        **** gov LP (missing lp_total_gov_share means no gov shares, 0 means gov shares but percentages are missing); lptype_en to include GGF and government bureau as gov LP ****
        gen lpgov_relate = ((lp_total_gov_share>=0& !missing(lp_total_gov_share)) | inlist(lptype_en,"Government Guide Fund","Government Bureau "))
        label var lpgov_relate "Gov-related LPs"
        **** gov GP (missing gp_total_gov_share means no gov shares, 0 means gov shares but percentages are missing) ****
        gen gpgov_relate = (gp_total_gov_share>=0 & !missing(gp_total_gov_share))
        label var gpgov_relate "Gov-related GPs"
        
        **** quality measures: gp_topranked gp_comprehensive_return  ******
        gen gpabovemedian = (gp_comprehensive_return_std>=$gp_cr_med & !missing(gp_comprehensive_return_std))
		*** also, if top ranked, take it as high quality ***
		replace gpabovemedian = (gp_topranked==1) if gpabovemedian == 0 
        label var gpabovemedian "High Quality GPs"
        
		***** Table : Gov VS Gov *******
		gen type_gov = 1 if gpgov_relate==1 & lpgov_relate==1 // Gov GP + Gov LP
        replace type_gov = 2 if gpgov_relate==0 & lpgov_relate==1 // Non-Gov GP + Gov LP
        replace type_gov = 3 if gpgov_relate==1 & lpgov_relate==0 // Gov GP + Non-Gov LP
        replace type_gov = 4 if gpgov_relate==0 & lpgov_relate==0 // Non-Gov GP + Non-Gov LP
        label var type_gov "Link Type based on Gov GP VS Gov LP"
        qui tab type_gov, matcell(gov_prob)

        **** distribution of every link type ***  
        global gov_both = gov_prob[1,1]
        global gov_lp_nongov_gp = gov_prob[2,1]
        global gov_gp_nongov_lp = gov_prob[3,1]
        global gov_neither = gov_prob[4,1]

        **** distribution of GP/LP types among unique GP/LP with links in the ownership sample ****
        **** used as probability in the denominator when calculating the likelihood ratio ****   
        preserve
                keep gp_fullname gpgov_relate
                duplicates drop

                qui tab gpgov_relate, matcell(gov)
                global gp_gov = gov[2,1]/_N
                global gp_nogov = gov[1,1]/_N
        restore
        preserve
                keep lp_fullname lpgov_relate
                duplicates drop
                qui tab lpgov_relate, matcell(gov)
                global lp_gov = gov[2,1]/_N
                global lp_nogov = gov[1,1]/_N
        restore  
        global t_link = _N
        **** generate matrix number = (observed probability of type ij link)/ ((probability of type i GP)*(probability of type j LP)) ****
        global g11 = $gov_both / ($gp_gov * $lp_gov * $t_link )
        global g12 = $gov_lp_nongov_gp /($gp_nogov * $lp_gov * $t_link )
        global g21 = $gov_gp_nongov_lp /($gp_gov * $lp_nogov * $t_link )
        global g22 = $gov_neither /($gp_nogov * $lp_nogov * $t_link )
        global g_index = ($gov_both + $gov_neither )/ ($gp_gov * $lp_gov * $t_link + $gp_nogov *$lp_nogov * $t_link )

        ***************** construct the matrix output in latex *******
        *** col ratio and row ratio ***
        global g13: dis %6.3f $g11 / $g21
        global g23: dis %6.3f $g12 / $g22
        global g31: dis %6.3f $g11 / $g12
        global g32: dis %6.3f $g21 / $g22
        *** distribution of type ij link ***
        global p1: dis %8.2f $gov_both *100/$t_link
        global p2: dis %8.2f $gov_gp_nongov_lp *100/$t_link
        global p3: dis %8.2f $gov_lp_nongov_gp *100/$t_link
        global p4: dis %8.2f $gov_neither *100/$t_link
        foreach var in g11 g12 g21 g22 g_index {
                global `var': dis %6.3f ${`var'}
        }
        
        ********************* p-value for Col Ratio and Row Ratio ----- Binomial Test *******
        qui bitesti ($gov_both+$gov_gp_nongov_lp) $gov_both   $lp_gov
        global p_colrat1: dis %6.3f `r(p)'
        qui bitesti ($gov_lp_nongov_gp+$gov_neither) $gov_lp_nongov_gp $lp_gov
        global p_colrat2: dis %6.3f `r(p)'
        qui bitesti ($gov_both+$gov_lp_nongov_gp) $gov_both $gp_gov
        global p_rowrat1: dis %6.3f `r(p)'
        qui bitesti ($gov_gp_nongov_lp+$gov_neither) $gov_gp_nongov_lp $gp_gov
        global p_rowrat2: dis %6.3f `r(p)'        
        
        **** chi2 test for homogeneity *****
		/*==================================
		Table: Assortative Matching Between Government-Owned GPs and LPs
		===================================*/
        qui tabulate gpgov_relate lpgov_relate, chi2
        global p_chi_gg: dis %6.3f `r(p)'
                
                local file "$maintable_dir/Table4.tex"
                cap file close file1 
                file open file1 using "`file'", write replace
                file write file1 "\begin{tabular}{lccc}  \hline\hline " _n
                file write file1 "  &  Gov LP&Non-Gov LP& ColRatio\\"
                file write file1 "Gov GP & $g11 & $g21 & $g13 \\"
                file write file1 "& ($p1 \%) & ($p2 \%) & ($p_colrat1) \\"
                file write file1 "Non-Gov GP & $g12 & $g22 & $g23 \\"
                file write file1 "& ($p3 \%) & ($p4 \%) & ($p_colrat2)\\"
                file write file1 "RowRatio & $g31 & $g32 & \\"
                file write file1 " & ($p_rowrat1) & ($p_rowrat2) & \\"
                file write file1 "\midrule"
                file write file1 "\textbf{Assortative Index}& \multicolumn{3}{c}{$g_index }\\"
                file write file1 "Homogeneity Test(p-value) & \multicolumn{3}{c}{$p_chi_gg }\\"
                file write file1 "\hline\hline \end{tabular}" 
                file close file1 
		
/*==============================================================================
Table 5. GP Preferences for LPs
===============================================================================*/
use "$survey_dir/gp_survey_data_regress.dta", clear

	drop if gp_id=="CAU"| gp_id=="FMZ" | gp_id=="OEJ"| gp_id=="QET"| gp_id=="QYN"| gp_id=="UTL"| gp_id=="UYM"| gp_id=="VUI"| gp_id=="XAJ"| gp_id=="XLJ"
	merge m:1 lp_profile_id using "$survey_dir/lp_profile_everyoption.dta", nogen keep(3)
	
	****** regrouping ****
	replace lp_ideology = 1 if stage_2 == 1
	replace lp_investment_stage = 0 if stage_2==1 | stage_5 == 1
	label var lp_investment_stage "Stage Focus"
	
	replace lp_aum = 0 if lp_aum<3
	replace lp_aum = 1 if lp_aum>=3 & !missing(lp_aum)
	label var lp_aum "Large Investor"
	
	**** relabeling ***
	label var lp_registered_cap_value "High Registered Capital"
	
******** gp choose lp regression (specifications) *****
global mainvar lp_relation_gov lp_aum lp_registered_cap_value lp_industry lp_post_2010 lp_foreign_dummy lp_beijing_dummy lp_compliance lp_ideology lp_investment_stage 
global control1 lp_invest_restriction lp_top lp_team_connection lp_team_experience
global fe_model i.gp_fe

global speci1 $mainvar 
global speci2 $mainvar $control1
global speci3 $speci1 $fe_model	
global speci4 $speci2 $fe_model


*Cooperation Interest (Meeting Dummy) / Partner Rating / Expected Interests*
foreach var in q2 {
	if "`var'"=="q1" {
        	local c_note = "m"
        }
        else if "`var'" == "q2" {
        	local c_note = "i"
        }
        else {
        	local c_note = "a"
        }
        ************** gov-affiliated GP ******************
        qui sum `var' 
        global mean_dp_all:dis %6.3f `r(mean)' 
        global sd_dp_all: dis %6.3f `r(sd)' 

        forval i=1(1)4 {
                eststo col`i'_all_`c_note': qui reg `var' ${speci`i'}, robust
                        if `i'<=2 {
                                estadd local l_fe "No", replace
                        }
                        else {
                                estadd local l_fe "Yes", replace
                        }
                        qui tab gp_id if _est_col`i'_all_`c_note'
                        estadd local u_id `r(r)', replace
                        estadd local model_des "OLS"
                        estadd local mean $mean_dp_all
                        estadd local sd $sd_dp_all
        }
}

**** output table 2 *******
esttab col1_all_i col3_all_i using "$maintable_dir/Table5.tex", label booktabs eqlabels(none) replace ///
	star(* 0.1 ** 0.05 *** 0.01) t(%6.2f) b(%8.3f)  ///
        stats(N u_id r2 l_fe model_des mean sd,labels("Observations" "Unique GPs" "R-Squared"  "GP FEs" "Model" "DV Mean" "DV SD") fmt(a3 a3 %8.3f a3 a3 %6.3f %6.3f)) ///
	mtitle("Partner" "Rating") title("GP Preferences for LPs") ///
	drop(*gp_fe _cons) 
	
	/*==============================================================================
Table 6. LP Preferences for GPs
===============================================================================*/
use "$survey_dir/lp_survey_data_regress.dta", clear

	drop if lp_id == "MLD"

	merge m:1 gp_profile_id using "$survey_dir/gp_profile_everyoption.dta", nogen keep(3)
	
***** regrouping and relabelling ****
label var gp_fund "Serial Fund Manager"
replace gp_fund = 1 if gp_fund>0 


label var gp_invest "Exits"
replace gp_invest = 0 if invest_1 == 1 | invest_5 == 1
replace gp_invest = 1 if invest_2==1 | invest_3==1 | invest_4==1 | invest_6==1 | invest_7==1 | invest_8==1

label var gp_irr "High IRR"
replace gp_irr = 1 if irr_5 ==1  | irr_6 ==1 | irr_7==1 | irr_8==1
replace gp_irr = 0 if irr_1 == 1 | irr_2==1 | irr_3==1 | irr_4==1

label var gp_aum "High AUM"
replace gp_aum = 0 if gp_aum<2
replace gp_aum = 1 if gp_aum>=2 & !missing(gp_aum)

label var gp_vcpe "VC"
label var gp_top "Ranked GP"

replace gp_relation_gov = 1 if relation_gov_1 == 1 | relation_gov_2 == 1
replace gp_relation_gov = 0 if relation_gov_3 == 1 

****** LP choose GP regression ****
/* set specifications first */
global mainvar gp_relation_gov
global control1 gp_team_connection gp_team_experience gp_aum gp_irr gp_invest gp_top gp_industry gp_post_2010 gp_foreign_dummy gp_beijing_dummy gp_vcpe 
global control2 gp_market gp_ideology gp_have_stage gp_invest_horizon gp_fund  
global fe_model i.lp_fe


global speci3 $mainvar $control1 $control2
global speci6 $speci3 $fe_model
  
/*==============================
Partner Grading
================================*/

qui sum q2
local mean_dp: dis %6.3f `r(mean)'
local sd_dp: dis %6.3f `r(sd)'

forval i=3(3)6 {
	eststo col`i'_c: qui reg q2 ${speci`i'}, robust
                if `i'<=3 {
                        estadd local l_fe "No", replace
                }
                else {
                	estadd local l_fe "Yes", replace
                }
                qui tab lp_id if _est_col`i'_c
                estadd local u_id `r(r)', replace
                estadd local model_des "OLS"
                estadd local mean `mean_dp'
                estadd local sd `sd_dp'       
}

esttab col3_c col6_c using "$maintable_dir/Table6.tex", label booktabs eqlabels(none) replace ///
	star(* 0.1 ** 0.05 *** 0.01) t(%6.2f) b(%8.3f)  ///
        stats(N u_id r2 l_fe model_des mean sd,labels("Observations" "Unique LPs" "R-Squared"  "LP FEs" "Model" "DV Mean" "DV SD") fmt(a3 a3 %8.3f a3 a3 %6.3f %6.3f)) ///
	mtitle("Partner" "Rating") title("LP Preferences for GPs") ///
	drop(*lp_fe _cons) 
	
/*==============================================================================
Table 7.  GP Preferences for LPs: Heterogeneity across Government Levels
===============================================================================*/
use "$survey_dir/gp_survey_data_regress.dta", clear

	drop if gp_id=="CAU"| gp_id=="FMZ" | gp_id=="OEJ"| gp_id=="QET"| gp_id=="QYN"| gp_id=="UTL"| gp_id=="UYM"| gp_id=="VUI"| gp_id=="XAJ"| gp_id=="XLJ"

	merge m:1 lp_profile_id using "$survey_dir/lp_profile_everyoption.dta", nogen keep(3)
	
	****** regrouping effort 1 ****
	replace lp_ideology = 1 if stage_2 == 1
	replace lp_investment_stage = 0 if stage_2==1 | stage_5 == 1
	
	label var lp_investment_stage "Stage Focus"
	
	**** regrouping effort 2 ****
	label var lp_invest_restriction "GGF Extra Details"
	
	***** regrouping effort 3 *****
	replace lp_aum = 0 if lp_aum<3
	replace lp_aum = 1 if lp_aum>=3 & !missing(lp_aum)
	label var lp_aum "Large Investor"
	
	gen govties_central = (relation_5==1)
	gen govties_provincial = (relation_6==1 | relation_7==1 | relation_8==1 | relation_9==1)
	gen govties_local = (relation_10==1 | relation_11==1)
	
	label var govties_central "GovTies-Central"
	label var govties_provincial "GovTies-Provincial"
	label var govties_local "GovTies-Local"
	
	**** relabeling ***
	label var lp_registered_cap_value "High Registered Capital"

	forvalues num = 1/11{
		label var relation_`num' "Gov Ties Option `num'"
	}
	
	
	
******** gp choose lp regression (specifications) *****
global mainvar govties_central govties_provincial govties_local lp_aum lp_registered_cap_value lp_industry lp_post_2010 lp_foreign_dummy lp_beijing_dummy lp_compliance lp_ideology lp_investment_stage 
global control1 lp_invest_restriction lp_top lp_team_connection lp_team_experience
global fe_model i.gp_fe

global speci1 $mainvar 
global speci2 $mainvar $control1
global speci3 $speci1 $fe_model	
global speci4 $speci2 $fe_model


*Cooperation Interest (Meeting Dummy) / Partner Rating / Expected Interests*
foreach var in q2 {
	if "`var'"=="q1" {
        	local c_note = "m"
        }
        else if "`var'" == "q2" {
        	local c_note = "i"
        }
        else {
        	local c_note = "a"
        }
        ************** gov-affiliated GP ******************
        qui sum `var' 
        global mean_dp_all:dis %6.3f `r(mean)' 
        global sd_dp_all: dis %6.3f `r(sd)' 

        forval i=1(1)4 {
                eststo col`i'_all_`c_note': qui reg `var' ${speci`i'}, robust
                        if `i'<=2 {
                                estadd local l_fe "No", replace
                        }
                        else {
                                estadd local l_fe "Yes", replace
                        }
                        qui tab gp_id if _est_col`i'_all_`c_note'
                        estadd local u_id `r(r)', replace
                        estadd local model_des "OLS"
                        estadd local mean $mean_dp_all
                        estadd local sd $sd_dp_all
        }
}

**** output table 2 *******
esttab col1_all_i col3_all_i using "$maintable_dir/Table7.tex", label booktabs eqlabels(none) replace ///
	star(* 0.1 ** 0.05 *** 0.01) t(%6.2f) b(%8.3f)  ///
        stats(N u_id r2 l_fe model_des mean sd,labels("Observations" "Unique GPs" "R-Squared"  "GP FEs" "Model" "DV Mean" "DV SD") fmt(a3 a3 %8.3f a3 a3 %6.3f %6.3f)) ///
	mtitle("Partner" "Rating") title("GP Preferences for LPs: Heterogeneity across Government Levels") ///
	drop(*gp_fe _cons) 

/*==============================================================================
Table 8. GP Preferences for LPs: Heterogeneity by Government-Owned GPs
===============================================================================*/
use "$survey_dir/gp_survey_data_regress.dta", clear

	drop if gp_id=="CAU"| gp_id=="FMZ" | gp_id=="OEJ"| gp_id=="QET"| gp_id=="QYN"| gp_id=="UTL"| gp_id=="UYM"| gp_id=="VUI"| gp_id=="XAJ"| gp_id=="XLJ"

	merge m:1 lp_profile_id using "$survey_dir/lp_profile_everyoption.dta", nogen keep(3)
	
	****** regrouping effort ****
	replace lp_ideology = 1 if stage_2 == 1
	replace lp_investment_stage = 0 if stage_2==1 | stage_5 == 1
	label var lp_investment_stage "Stage Focus"

	replace lp_aum = 0 if lp_aum<3
	replace lp_aum = 1 if lp_aum>=3 & !missing(lp_aum)
	label var lp_aum "Large Investor"
	
	**** relabeling ***
	label var lp_registered_cap_value "High Registered Capital"
	
	
******** gp choose lp regression *****
global mainvar lp_relation_gov lp_aum lp_registered_cap_value lp_industry lp_post_2010 lp_foreign_dummy lp_beijing_dummy lp_compliance lp_ideology lp_investment_stage 
global control1 lp_invest_restriction lp_top lp_team_connection lp_team_experience
global fe_model i.gp_fe

global speci1 $mainvar 
global speci2 $mainvar $control1
global speci3 $speci1 $fe_model	
global speci4 $speci2 $fe_model


gen gov_cri_1 = (gp_total_gov_share>=0 & !missing(gp_total_gov_share)) 

*Partner Rating *
foreach var in q2 {
	if "`var'"=="q1" {
        	local c_note = "m"
        }
        else if "`var'" == "q2" {
        	local c_note = "i"
        }
        else {
        	local c_note = "a"
        }
        ************** gov-affiliated GP ******************
        qui sum `var' if gov_cri_1 == 1
        global mean_dp_all:dis %6.3f `r(mean)' 
        global sd_dp_all: dis %6.3f `r(sd)' 
		
		qui sum `var' if gov_cri_1 == 0 
        global mean_dp_full:dis %6.3f `r(mean)' 
        global sd_dp_full: dis %6.3f `r(sd)' 

        forval i=1(2)3 {
                eststo col`i'_all_`c_note': qui reg `var' ${speci`i'} if gov_cri_1==1, robust
                        if `i'<=2 {
                                estadd local l_fe "No", replace
                        }
                        else {
                                estadd local l_fe "Yes", replace
                        }
                        qui tab gp_id if _est_col`i'_all_`c_note'
                        estadd local u_id `r(r)', replace
                        estadd local model_des "OLS"
                        estadd local mean $mean_dp_all
                        estadd local sd $sd_dp_all

				eststo col`i'_full_`c_note': qui reg `var' ${speci`i'} if gov_cri_1==0, robust
                        if `i'<=2 {
                                estadd local l_fe "No", replace
                        }
                        else {
                                estadd local l_fe "Yes", replace
                        }
                        qui tab gp_id if _est_col`i'_full_`c_note'
                        estadd local u_id `r(r)', replace
                        estadd local model_des "OLS"
                        estadd local mean $mean_dp_full
                        estadd local sd $sd_dp_full
        }
}

**** two tables for different samples *******
esttab col1_all_i col1_full_i col3_all_i col3_full_i using "$maintable_dir/Table8_regression.tex", label booktabs eqlabels(none) replace ///
	star(* 0.1 ** 0.05 *** 0.01) t(%6.2f) b(%8.3f)  ///
        stats(N u_id r2 l_fe model_des mean sd,labels("Observations" "Unique GPs" "R-Squared"  "GP FEs" "Model" "DV Mean" "DV SD") fmt(a3 a3 %8.3f a3 a3 %6.3f %6.3f)) ///
	mtitle("Gov" "Non-Gov" "Gov" "Non-Gov") title("GP Preferences for LPs: Heterogeneity by Government-Owned GPs") ///
	drop(*gp_fe _cons) 

**** test coefficient ****
bysort gp_fe: center q1 q2 q3, prefix(cy_)
bysort gp_fe: center $speci1, prefix(cx_)
*** gov_affiliated GP vs non_gov_affiliated GP ***
*Cooperation Interest (Meeting Dummy) Partner Grading  Expected Interests  for different samples*
foreach var in q2 {
	if "`var'"=="q1" {
        	local c_note = "m"
        }
        else if "`var'" == "q2" {
        	local c_note = "i"
        }
        else {
        	local c_note = "a"
        }
	************** gov-affiliated GP ******************
        eststo col3_all_`c_note': qui reg `var' $speci1 if gov_cri_1==1
        eststo col6_all_`c_note': qui reg cy_`var' cx_* if gov_cri_1==1
       
        ****** non gov-affiliated GP *****
        eststo col3_all_n_`c_note': qui reg `var' $speci1 if gov_cri_1==0
        eststo col6_all_n_`c_note': qui reg cy_`var' cx_* if gov_cri_1==0

        ***** generate the estimator comparison for two groups for the same dep var ****
        
        ***** all sample ***
        eststo com1_all_`c_note': qui suest col3_all_`c_note' col3_all_n_`c_note', vce(robust)
        foreach var in $speci1 {
                qui test [col3_all_`c_note'_mean]`var'=[col3_all_n_`c_note'_mean]`var'
                estadd scalar `var' = r(p)
                
        }
        estadd local l_fe "No" 

        eststo com2_all_`c_note': qui suest col6_all_`c_note' col6_all_n_`c_note', vce(robust)
        foreach var in $speci1 {
                qui test [col6_all_`c_note'_mean]cx_`var'=[col6_all_n_`c_note'_mean]cx_`var'
                estadd scalar `var' = r(p)        
        }
        estadd local l_fe "Yes" 
        
        
}

esttab com1_all_i com2_all_i using "$maintable_dir/Table8_SURtest.tex", label booktabs eqlabels(none) replace stats($speci1 l_fe, label("Government Ties" "Large Investor" "High Registered Capital" "Industry Information" "Young LP" "Headquarter In Foreign Country" "Headquarter In Beijing" "Corporate Governance" "Investment Philosophy" "Stage Focus" "GP FEs") fmt(%8.3f %8.3f %8.3f %8.3f %8.3f %8.3f %8.3f %8.3f %8.3f %8.3f %8.3f a3)) ///
        mtitle("P-Value" "P-Value") title("Difference in Coefficients (p-value) Gov VS Non-Gov (Full Sample)") drop(*)

eststo clear

**** to form the final table, use a simple Python code to transform the latex files （text_gene.py）***


				
/*******************************************************************************
********************************************************************************

**********************           Appendix           ****************************

********************************************************************************
*******************************************************************************/
/*==============================================================================
Table A1. Comparing Active and Inactive Entities in the Zero2IPO Database
see R code in the folder 
===============================================================================*/

/*==============================================================================
Table A2. Comparing Respondents and Non-Respondents
see R code in the folder 
===============================================================================*/


/*==============================================================================
Table A3. Government-Owned GPs Perform Worse (Respondents Only)
===============================================================================*/
use "$zero2ipo_dir/GP_performance_details.dta", clear
	keep GP_fullname gp* assort_sample
	ren *, lower
	tempfile performance
	save `performance', replace

use "$zero2ipo_dir/ActiveOwnershipGP_2015-19_SummaryStats.dta", clear
	keep gp_fullname hq_province_group
	tempfile hqnew
	save `hqnew', replace
	
***** gp regression ****
use "$zero2ipo_dir/gp_ownershipsample_info.dta", clear
		**** keep if assort_sample == 1
		merge 1:1 gp_fullname using `hqnew', nogen keep(3)
		
        **** gen hq fe for regressions (missing gp_hq_province_group are not included) ***
        encode hq_province_group, gen(gphq)
		label var gphq "GP HQ fixed effects"
		
        **** gov GP (missing gp_total_gov_share means no gov shares, 0 means gov shares but percentages are missing) ****
        gen gpgov_relate = (gp_total_gov_share >=0 & !missing(gp_total_gov_share))  	
        label var gpgov_relate "Gov GPs"
		drop gp_rank_comprehensivereturn gp_irr  
		merge 1:1 gp_fullname using `performance', nogen keep(3)

		
**** link sample ****
*keep if assort_sample == 1
       **** gov GP (missing gp_total_gov_share means no gov shares, 0 means gov shares but percentages are missing) ****
        replace gpgov_relate = (gp_total_gov_share >=0 & !missing(gp_total_gov_share ))  	
       
local model_num = 0
label var gp_rank_fundraisingusd "Fund Raising Amount"
egen min_gp_comprehensive_return = min(gp_comprehensive_return)
egen max_gp_comprehensive_return = max(gp_comprehensive_return)
gen gp_comprehensive_return_std = (gp_comprehensive_return - min_gp_comprehensive_return)/(max_gp_comprehensive_return - min_gp_comprehensive_return)

winsor gp_irr, gen(W_gp_irr) p(0.05) highonly
winsor gp_rank_aumusd, gen(W_gp_rank_aumusd) p(0.05) highonly
label var W_gp_rank_aumusd "AUM"

keep if gp_respondent == 1

foreach var in gp_comprehensive_return_std  W_gp_irr {
        local model_num = `model_num' + 1
        eststo col1_`model_num': qui reg `var' gpgov_relate, robust
                estadd local hq_fe "No"
               
        eststo col2_`model_num': qui reg `var' gpgov_relate i.gphq, robust
                estadd local hq_fe "Yes"
				
		eststo col3_`model_num': qui reg `var' gpgov_relate W_gp_rank_aumusd, robust
                estadd local hq_fe "No"
		
		eststo col4_`model_num': qui reg `var' gpgov_relate W_gp_rank_aumusd i.gphq, robust
				estadd local hq_fe "Yes"
}
	
esttab col1_1 col2_1 col3_1 col4_1 col1_2 col2_2 col3_2 col4_2 using "$appendixtable_dir/TableA3.tex", label booktabs eqlabels(none) replace ///
	star(* 0.1 ** 0.05 *** 0.01) t(%6.2f) b(%8.3f)  ///
        stats(N r2 hq_fe ,labels("Observations" "R-Squared"  "HQ FEs" ) fmt(a3 %8.3f a3)) ///
	mtitle("CR" "CR" "CR" "CR" "IRR" "IRR" "IRR" "IRR") title("Government-Owned GPs Perform Worse (Respondents Only)") ///
	drop(*gphq _cons) 
	
eststo clear	
/*==============================================================================
Table A4. Assortative Matching Between Government-Owned GPs and LPs (Respondents Only)
===============================================================================*/
* import gp performance data
use "$zero2ipo_dir/GP_performance_details.dta", clear
	ren *, lower

	replace gp_irr = gp_irr_1090 
keep gp_fullname gp_exit_invest gp_irr gp_comprehensive_return
	tempfile cr2win
	save `cr2win', replace



**** could get median here if want to impute later, same for lp performance measures ***

use "$zero2ipo_dir/gp_ownershipsample_info.dta", clear
	keep gp_fullname gp_respondent
	tempfile gpresp
	save `gpresp', replace


*tempfile gp_perform
*save `gp_perform', replace

***** link perform data to assortative matching sample ****
use "$zero2ipo_dir/assortativematching_newactivesample.dta", clear
		***** note that the data set includes link_year link_amount link_total_lp for each link between GP-LP pairs ****
        ***** a GP-LP pair may appear in the data sets more than once if they have links in different fundraising events ****
        duplicates drop // unique GP-LP pairs
		
		merge m:1 gp_fullname using `cr2win', nogen keep(3)
		merge m:1 gp_fullname using `gpresp', nogen keep(3)
		keep if gp_respondent==1
		*merge m:1 gp_fullname using `gp_perform', nogen
		egen min_gp_comprehensive_return = min(gp_comprehensive_return)
		egen max_gp_comprehensive_return = max(gp_comprehensive_return)
		gen gp_comprehensive_return_std = (gp_comprehensive_return - min_gp_comprehensive_return)/(max_gp_comprehensive_return - min_gp_comprehensive_return)
		
		qui sum gp_exit_invest, de
		global gp_exit_invest_med = `r(p50)'
		qui sum gp_comprehensive_return_std, de
		global gp_cr_med = `r(p50)'
		qui sum gp_irr, de
		global gp_irr_med = `r(p50)'
		
****** the next main step: gen quality/gov measure for GP & gov measure for LP *********
****** generate gov LP, gov GP and high quality GP ****
        **** gov LP (missing lp_total_gov_share means no gov shares, 0 means gov shares but percentages are missing) ****
        **** lptype_en to include GGF and government bureau as gov LP ****
        gen lpgov_relate = ((lp_total_gov_share>=0& !missing(lp_total_gov_share)) | inlist(lptype_en,"Government Guide Fund","Government Bureau "))
        label var lpgov_relate "Gov-related LPs"
        **** gov GP (missing gp_total_gov_share means no gov shares, 0 means gov shares but percentages are missing) ****
        **** other gov variables: gpgov_relate_by_lp_2016 and gpgov_relate_by_lp_2018 (if use these two defs, may restrict links to 2016-2019 and 2018-2019 respectively) ****
        gen gpgov_relate = (gp_total_gov_share>=0 & !missing(gp_total_gov_share))
        label var gpgov_relate "Gov-related GPs"
        

        **** quality measures: gp_topranked gp_comprehensive_return gp_exit_invest_1 gp_irr ******
        gen gpabovemedian = (gp_comprehensive_return_std>=$gp_cr_med & !missing(gp_comprehensive_return_std))
		*** also, if top ranked, take it as high quality ***
		replace gpabovemedian = (gp_topranked==1) if gpabovemedian == 0 
		
		
        label var gpabovemedian "High Quality GPs"
        
		***** Table 8: Gov VS Gov *******
		gen type_gov = 1 if gpgov_relate==1 & lpgov_relate==1 // Gov GP + Gov LP
        replace type_gov = 2 if gpgov_relate==0 & lpgov_relate==1 // Non-Gov GP + Gov LP
        replace type_gov = 3 if gpgov_relate==1 & lpgov_relate==0 // Gov GP + Non-Gov LP
        replace type_gov = 4 if gpgov_relate==0 & lpgov_relate==0 // Non-Gov GP + Non-Gov LP
        label var type_gov "Link Type based on Gov GP VS Gov LP"
        qui tab type_gov, matcell(gov_prob)

        **** distribution of every link type ***  
        global gov_both = gov_prob[1,1]
        global gov_lp_nongov_gp = gov_prob[2,1]
        global gov_gp_nongov_lp = gov_prob[3,1]
        global gov_neither = gov_prob[4,1]

        **** distribution of GP/LP types among unique GP/LP with links in the ownership sample ****
        **** used as probability in the denominator when calculating the likelihood ratio ****   
        preserve
                keep gp_fullname gpgov_relate
                duplicates drop

                qui tab gpgov_relate, matcell(gov)
                global gp_gov = gov[2,1]/_N
                global gp_nogov = gov[1,1]/_N
        restore
        preserve
                keep lp_fullname lpgov_relate
                duplicates drop
                qui tab lpgov_relate, matcell(gov)
                global lp_gov = gov[2,1]/_N
                global lp_nogov = gov[1,1]/_N
        restore  
        global t_link = _N
        **** generate matrix number = (observed probability of type ij link)/ ((probability of type i GP)*(probability of type j LP)) ****
        global g11 = $gov_both / ($gp_gov * $lp_gov * $t_link )
        global g12 = $gov_lp_nongov_gp /($gp_nogov * $lp_gov * $t_link )
        global g21 = $gov_gp_nongov_lp /($gp_gov * $lp_nogov * $t_link )
        global g22 = $gov_neither /($gp_nogov * $lp_nogov * $t_link )
        global g_index = ($gov_both + $gov_neither )/ ($gp_gov * $lp_gov * $t_link + $gp_nogov *$lp_nogov * $t_link )

        ***************** construct the matrix output in latex *******
        *** col ratio and row ratio ***
        global g13: dis %6.3f $g11 / $g21
        global g23: dis %6.3f $g12 / $g22
        global g31: dis %6.3f $g11 / $g12
        global g32: dis %6.3f $g21 / $g22
        *** distribution of type ij link ***
        global p1: dis %8.2f $gov_both *100/$t_link
        global p2: dis %8.2f $gov_gp_nongov_lp *100/$t_link
        global p3: dis %8.2f $gov_lp_nongov_gp *100/$t_link
        global p4: dis %8.2f $gov_neither *100/$t_link
        foreach var in g11 g12 g21 g22 g_index {
                global `var': dis %6.3f ${`var'}
        }
        
        
        ********************* p-value for Col Ratio and Row Ratio ----- Binomial Test *******
        qui bitesti ($gov_both+$gov_gp_nongov_lp) $gov_both   $lp_gov
        global p_colrat1: dis %6.3f `r(p)'
        qui bitesti ($gov_lp_nongov_gp+$gov_neither) $gov_lp_nongov_gp $lp_gov
        global p_colrat2: dis %6.3f `r(p)'
        qui bitesti ($gov_both+$gov_lp_nongov_gp) $gov_both $gp_gov
        global p_rowrat1: dis %6.3f `r(p)'
        qui bitesti ($gov_gp_nongov_lp+$gov_neither) $gov_gp_nongov_lp $gp_gov
        global p_rowrat2: dis %6.3f `r(p)'        
        
        **** chi2 test for homogeneity *****
		/*==================================
		Table 7: Assortative Matching Between Government-Owned GPs and LPs
		===================================*/
        qui tabulate gpgov_relate lpgov_relate, chi2
        global p_chi_gg: dis %6.3f `r(p)'
                
                local file "$appendixtable_dir/TableA4.tex"
                cap file close file1 
                file open file1 using "`file'", write replace
                file write file1 "\begin{tabular}{lccc}  \hline\hline " _n
                file write file1 "  &  Gov LP&Non-Gov LP& ColRatio\\"
                file write file1 "Gov GP & $g11 & $g21 & $g13 \\"
                file write file1 "& ($p1 \%) & ($p2 \%) & ($p_colrat1) \\"
                file write file1 "Non-Gov GP & $g12 & $g22 & $g23 \\"
                file write file1 "& ($p3 \%) & ($p4 \%) & ($p_colrat2)\\"
                file write file1 "RowRatio & $g31 & $g32 & \\"
                file write file1 " & ($p_rowrat1) & ($p_rowrat2) & \\"
                file write file1 "\midrule"
                file write file1 "\textbf{Assortative Index}& \multicolumn{3}{c}{$g_index }\\"
                file write file1 "Homogeneity Test(p-value) & \multicolumn{3}{c}{$p_chi_gg }\\"
                file write file1 "\hline\hline \end{tabular}" 
                file close file1 
		


/*==============================================================================
Table A5. LP Type Distribution 
	see R code in the folder
===============================================================================*/
/*==============================================================================
Table A6. Summary Statistics by Government Level
	see R code in the folder 
===============================================================================*/

/*==============================================================================
Table A7. Variables in Synthetic LP Profiles
	no code
===============================================================================*/

/*==============================================================================
Table A8. Description of LP Profiles Randomized Components
	no code
===============================================================================*/
/*==============================================================================
Table A9.  Years of Experience in the Firm of Targeted Respondents
===============================================================================*/

**Panel A:All**
use "$survey_dir/1000respondent_list.dta", clear

eststo a: estpost tabstat workingyear2021,s(n mean sd p10 p25 median p75 p90)by(position)
esttab a using "$appendixtable_dir/TableA9_PanelA.tex",cells("count mean(fmt(2)) sd(fmt(2)) p10 p25 p50 p75 p90") noobs 
**Panel B:GPs**
duplicates drop gp_fullname,force

eststo b: estpost tabstat workingyear2021 if gp==1,s(n mean sd p10 p25 median p75 p90)by(position)
esttab b using "$appendixtable_dir/TableA9_PanelB.tex",cells("count mean(fmt(2)) sd(fmt(2)) p10 p25 p50 p75 p90") noobs 
**Panel C:LPs**
duplicates drop gp_fullname,force

eststo c: estpost tabstat workingyear2021 if lp==1,s(n mean sd p10 p25 median p75 p90)by(position)
esttab c using "$appendixtable_dir/TableA9_PanelC.tex",cells("count mean(fmt(2)) sd(fmt(2)) p10 p25 p50 p75 p90") noobs 
/*==============================================================================
Table A10. GP Preferences for LPs: Expected Interest
===============================================================================*/
use "$survey_dir/gp_survey_data_regress.dta", clear

	drop if gp_id=="CAU"| gp_id=="FMZ" | gp_id=="OEJ"| gp_id=="QET"| gp_id=="QYN"| gp_id=="UTL"| gp_id=="UYM"| gp_id=="VUI"| gp_id=="XAJ"| gp_id=="XLJ"

	merge m:1 lp_profile_id using "$survey_dir/lp_profile_everyoption.dta", nogen keep(3)
	
	****** regrouping effort 1 ****
	replace lp_ideology = 1 if stage_2 == 1
	replace lp_investment_stage = 0 if stage_2==1 | stage_5 == 1
	
	label var lp_investment_stage "Stage Focus"
	
	**** regrouping effort 2 ****
	label var lp_invest_restriction "GGF Extra Details"
	
	***** regrouping effort 3 *****
	replace lp_aum = 0 if lp_aum<3
	replace lp_aum = 1 if lp_aum>=3 & !missing(lp_aum)
	label var lp_aum "Large Investor"
	
	**** relabeling ***
	label var lp_registered_cap_value "High Registered Capital"
	
******** gp choose lp regression (specifications) *****
global mainvar lp_relation_gov lp_aum lp_registered_cap_value lp_industry lp_post_2010 lp_foreign_dummy lp_beijing_dummy lp_compliance lp_ideology lp_investment_stage 
global control1 lp_invest_restriction lp_top lp_team_connection lp_team_experience
global fe_model i.gp_fe

global speci1 $mainvar 
global speci2 $mainvar $control1
global speci3 $speci1 $fe_model	
global speci4 $speci2 $fe_model


*Cooperation Interest (Meeting Dummy) / Partner Rating / Expected Interests*
foreach var in q3 {
	if "`var'"=="q1" {
        	local c_note = "m"
        }
        else if "`var'" == "q2" {
        	local c_note = "i"
        }
        else {
        	local c_note = "a"
        }
        ************** gov-affiliated GP ******************
        qui sum `var' 
        global mean_dp_all:dis %6.3f `r(mean)' 
        global sd_dp_all: dis %6.3f `r(sd)' 

        forval i=1(1)4 {
                eststo col`i'_all_`c_note': qui reg `var' ${speci`i'}, robust
                        if `i'<=2 {
                                estadd local l_fe "No", replace
                        }
                        else {
                                estadd local l_fe "Yes", replace
                        }
                        qui tab gp_id if _est_col`i'_all_`c_note'
                        estadd local u_id `r(r)', replace
                        estadd local model_des "OLS"
                        estadd local mean $mean_dp_all
                        estadd local sd $sd_dp_all
        }
}

**** output table 2 *******
esttab col1_all_a col3_all_a using "$appendixtable_dir/TableA10.tex", label booktabs eqlabels(none) replace ///
	star(* 0.1 ** 0.05 *** 0.01) t(%6.2f) b(%8.3f)  ///
        stats(N u_id r2 l_fe model_des mean sd,labels("Observations" "Unique GPs" "R-Squared"  "GP FEs" "Model" "DV Mean" "DV SD") fmt(a3 a3 %8.3f a3 a3 %6.3f %6.3f)) ///
	mtitle("Expected" "Interest")title("GP Preferences for LPs: Expected Interest") ///
	drop(*gp_fe _cons)				
				
/*==============================================================================
Table A11. GP Preferences for LPs (Ordered Probit)
===============================================================================*/
use "$survey_dir/gp_survey_data_regress.dta", clear

	drop if gp_id=="CAU"| gp_id=="FMZ" | gp_id=="OEJ"| gp_id=="QET"| gp_id=="QYN"| gp_id=="UTL"| gp_id=="UYM"| gp_id=="VUI"| gp_id=="XAJ"| gp_id=="XLJ"

	merge m:1 lp_profile_id using "$survey_dir/lp_profile_everyoption.dta", nogen keep(3)
	
	****** regrouping effort 1 ****
	replace lp_ideology = 1 if stage_2 == 1
	replace lp_investment_stage = 0 if stage_2==1 | stage_5 == 1
	
	label var lp_investment_stage "Stage Focus"
	
	**** regrouping effort 2 ****
	label var lp_invest_restriction "GGF Extra Details"
	
	***** regrouping effort 3 *****
	replace lp_aum = 0 if lp_aum<3
	replace lp_aum = 1 if lp_aum>=3 & !missing(lp_aum)
	label var lp_aum "Large Investor"
	
	**** relabeling ***
	label var lp_registered_cap_value "High Registered Capital"
	
******** gp choose lp regression (specifications) *****
global mainvar lp_relation_gov lp_aum lp_registered_cap_value lp_industry lp_post_2010 lp_foreign_dummy lp_beijing_dummy lp_compliance lp_ideology lp_investment_stage 
global control1 lp_invest_restriction lp_top lp_team_connection lp_team_experience
global fe_model i.gp_fe

global speci1 $mainvar 
global speci2 $mainvar $control1
global speci3 $speci1 $fe_model	
global speci4 $speci2 $fe_model

*Partner Rating (q2) / Expected Interests* (q3)
*** reg of Partner Rating (q2) ***
qui sum q2 
global mean_dp_all:dis %6.3f `r(mean)' 
global sd_dp_all: dis %6.3f `r(sd)' 

	* reg of Partner Rating (q2), without FEs
	eststo col1_all_i:  oprobit q2 ${speci1}, robust
		estadd local l_fe "No", replace
		qui tab gp_id if _est_col1_all_i
		estadd local u_id `r(r)', replace
		estadd local model_des "OLS"
		estadd local mean $mean_dp_all
		estadd local sd $sd_dp_all

	* reg of Partner Rating (q2), with FEs
	eststo col3_all_i:  oprobit q2 ${speci3}, robust
		estadd local l_fe "Yes", replace
		qui tab gp_id if _est_col3_all_i
		estadd local u_id `r(r)', replace
		estadd local model_des "OLS"
		estadd local mean $mean_dp_all
		estadd local sd $sd_dp_all

**** output table 2 *******
esttab col1_all_i col3_all_i using "$appendixtable_dir/TableA11.tex", label booktabs eqlabels(none) replace ///
	star(* 0.1 ** 0.05 *** 0.01) t(%6.2f) b(%8.3f)  ///
        stats(N u_id r2 l_fe model_des mean sd,labels("Observations" "Unique GPs" "R-Squared"  "GP FEs" "Model" "DV Mean" "DV SD") fmt(a3 a3 %8.3f a3 a3 %6.3f %6.3f)) ///
	mtitle("Partner" "Rating") title("GP Preferences for LPs(Ordered Probit)") ///
	drop(*gp_fe) 


/*==============================================================================
Table A12. GP Preferences for LPs: Cooperation Interest
===============================================================================*/
use "$survey_dir/gp_survey_data_regress.dta", clear

	drop if gp_id=="CAU"| gp_id=="FMZ" | gp_id=="OEJ"| gp_id=="QET"| gp_id=="QYN"| gp_id=="UTL"| gp_id=="UYM"| gp_id=="VUI"| gp_id=="XAJ"| gp_id=="XLJ"

	merge m:1 lp_profile_id using "$survey_dir/lp_profile_everyoption.dta", nogen keep(3)
	
	****** regrouping effort 1 ****
	replace lp_ideology = 1 if stage_2 == 1
	replace lp_investment_stage = 0 if stage_2==1 | stage_5 == 1
	
	label var lp_investment_stage "Stage Focus"
	
	**** regrouping effort 2 ****
	label var lp_invest_restriction "GGF Extra Details"
	
	***** regrouping effort 3 *****
	replace lp_aum = 0 if lp_aum<3
	replace lp_aum = 1 if lp_aum>=3 & !missing(lp_aum)
	label var lp_aum "Large Investor"
	
	**** relabeling ***
	label var lp_registered_cap_value "High Registered Capital"
	
******** gp choose lp regression (specifications) *****
global mainvar lp_relation_gov lp_aum lp_registered_cap_value lp_industry lp_post_2010 lp_foreign_dummy lp_beijing_dummy lp_compliance lp_ideology lp_investment_stage 
global control1 lp_invest_restriction lp_top lp_team_connection lp_team_experience
global fe_model i.gp_fe

global speci1 $mainvar 
global speci2 $mainvar $control1
global speci3 $speci1 $fe_model	
global speci4 $speci2 $fe_model

/*===================================
Cooperation Interest (Meeting Dummy) / Partner Rating / Expected Interests  
=====================================*/
foreach var in q1 {
	if "`var'"=="q1" {
        	local c_note = "m"
        }
        else if "`var'" == "q2" {
        	local c_note = "i"
        }
        else {
        	local c_note = "a"
        }
        ************** gov-affiliated GP ******************
        qui sum `var' 
        global mean_dp_all:dis %6.3f `r(mean)' 
        global sd_dp_all: dis %6.3f `r(sd)' 

        forval i=1(1)4 {
                eststo col`i'_all_`c_note': qui reg `var' ${speci`i'}, robust
                        if `i'<=2 {
                                estadd local l_fe "No", replace
                        }
                        else {
                                estadd local l_fe "Yes", replace
                        }
                        qui tab gp_id if _est_col`i'_all_`c_note'
                        estadd local u_id `r(r)', replace
                        estadd local model_des "OLS"
                        estadd local mean $mean_dp_all
                        estadd local sd $sd_dp_all
        }
}

**** output appendix table *******
esttab col1_all_m col3_all_m using "$appendixtable_dir/TableA12.tex", label booktabs eqlabels(none) replace ///
	star(* 0.1 ** 0.05 *** 0.01) t(%6.2f) b(%8.3f)  ///
        stats(N u_id r2 l_fe model_des mean sd,labels("Observations" "Unique GPs" "R-Squared"  "GP FEs" "Model" "DV Mean" "DV SD") fmt(a3 a3 %8.3f a3 a3 %6.3f %6.3f)) ///
	mtitle("Cooperation" "Interest") title("GP Preferences for LPs: Cooperation Interest")  ///
	drop(*gp_fe _cons) 
	
	
/*==============================================================================
Table A13. GP Preferences for LPs: Clustering SEs at Respondent Level
===============================================================================*/
use "$survey_dir/gp_survey_data_regress.dta", clear

	drop if gp_id=="CAU"| gp_id=="FMZ" | gp_id=="OEJ"| gp_id=="QET"| gp_id=="QYN"| gp_id=="UTL"| gp_id=="UYM"| gp_id=="VUI"| gp_id=="XAJ"| gp_id=="XLJ"

	merge m:1 lp_profile_id using "$survey_dir/lp_profile_everyoption.dta", nogen keep(3)
	
	****** regrouping effort ****
	replace lp_ideology = 1 if stage_2 == 1
	replace lp_investment_stage = 0 if stage_2==1 | stage_5 == 1
	label var lp_investment_stage "Stage Focus"
	
	replace lp_aum = 0 if lp_aum<3
	replace lp_aum = 1 if lp_aum>=3 & !missing(lp_aum)
	label var lp_aum "Large Investor"
	
	**** relabeling ***
	label var lp_registered_cap_value "High Registered Capital"
	
******** gp choose lp regression *****
global mainvar lp_relation_gov lp_aum lp_registered_cap_value lp_industry lp_post_2010 lp_foreign_dummy lp_beijing_dummy lp_compliance lp_ideology lp_investment_stage 
global control1 lp_invest_restriction lp_top lp_team_connection lp_team_experience
global fe_model i.gp_fe

global speci1 $mainvar 
global speci2 $mainvar $control1
global speci3 $speci1 $fe_model	
global speci4 $speci2 $fe_model

/*===================================
Cooperation Interest (Meeting Dummy) / Partner Rating / Expected Interests  
=====================================*/
foreach var in q2 {
	if "`var'"=="q1" {
        	local c_note = "m"
        }
        else if "`var'" == "q2" {
        	local c_note = "i"
        }
        else {
        	local c_note = "a"
        }
        ************** gov-affiliated GP ******************
        qui sum `var' 
        global mean_dp_all:dis %6.3f `r(mean)' 
        global sd_dp_all: dis %6.3f `r(sd)' 

        forval i=1(1)4 {
                eststo col`i'_all_`c_note': qui reg `var' ${speci`i'}, vce(cluster gp_id)
                        if `i'<=2 {
                                estadd local l_fe "No", replace
                        }
                        else {
                                estadd local l_fe "Yes", replace
                        }
                        qui tab gp_id if _est_col`i'_all_`c_note'
                        estadd local u_id `r(r)', replace
                        estadd local model_des "OLS"
                        estadd local mean $mean_dp_all
                        estadd local sd $sd_dp_all
        }
}

**** output table  *******
esttab col1_all_i col3_all_i using "$appendixtable_dir/TableA13.tex", label booktabs eqlabels(none) replace ///
	star(* 0.1 ** 0.05 *** 0.01) t(%6.2f) b(%8.3f)  ///
        stats(N u_id r2 l_fe model_des mean sd,labels("Observations" "Unique GPs" "R-Squared"  "GP FEs" "Model" "DV Mean" "DV SD") fmt(a3 a3 %8.3f a3 a3 %6.3f %6.3f)) ///
	mtitle("Partner" "Rating")title("GP Preferences for LPs: Clustering SEs at Respondent Level") ///
	drop(*gp_fe _cons) 
/*==============================================================================
Table A14. GP Preferences for LPs: Robustness Sample Spilts
===============================================================================*/
use "$survey_dir/GP_reg_individual_character_hetero.dta", clear

	drop if gp_id=="CAU"| gp_id=="FMZ" | gp_id=="OEJ"| gp_id=="QET"| gp_id=="QYN"| gp_id=="UTL"| gp_id=="UYM"| gp_id=="VUI"| gp_id=="XAJ"| gp_id=="XLJ"

	merge m:1 lp_profile_id using "$survey_dir/lp_profile_everyoption.dta", nogen keep(3)
	
	****** regrouping effort ****
	replace lp_ideology = 1 if stage_2 == 1
	replace lp_investment_stage = 0 if stage_2==1 | stage_5 == 1
	label var lp_investment_stage "Stage Focus"

	replace lp_aum = 0 if lp_aum<3
	replace lp_aum = 1 if lp_aum>=3 & !missing(lp_aum)
	label var lp_aum "Large Investor"
	
	**** relabeling ***
	label var lp_registered_cap_value "High Registered Capital"
	
	
******** gp choose lp regression *****
global mainvar lp_relation_gov lp_aum lp_registered_cap_value lp_industry lp_post_2010 lp_foreign_dummy lp_beijing_dummy lp_compliance lp_ideology lp_investment_stage 
global control1 lp_invest_restriction lp_top lp_team_connection lp_team_experience
global fe_model i.gp_fe

global speci1 $mainvar 
global speci2 $mainvar $control1
global speci3 $speci1 $fe_model	
global speci4 $speci2 $fe_model


gen gov_cri_1 = (gp_total_gov_share>=0 & !missing(gp_total_gov_share)) // many other gov definitions could be used here

*Partner Rating *
foreach var in q2 {
	if "`var'"=="q1" {
        	local c_note = "m"
        }
        else if "`var'" == "q2" {
        	local c_note = "i"
        }
        else {
        	local c_note = "a"
        }
        ************** gov-affiliated GP ******************
        qui sum `var' if positionmapped=="partners"
        global mean_dp_all1:dis %6.3f `r(mean)' 
        global sd_dp_all1: dis %6.3f `r(sd)' 
		
		qui sum `var' if positionmapped== "board of directors"
        global mean_dp_all2:dis %6.3f `r(mean)' 
        global sd_dp_all2: dis %6.3f `r(sd)' 
        
		qui sum `var' if man_exe== 1 
        global mean_dp_all3:dis %6.3f `r(mean)' 
        global sd_dp_all3: dis %6.3f `r(sd)' 
		
		qui sum `var' if positionmapped== "others"
        global mean_dp_all4:dis %6.3f `r(mean)' 
        global sd_dp_all4: dis %6.3f `r(sd)' 
		
		qui sum `var' if q3>=7
        global mean_dp_all5:dis %6.3f `r(mean)' 
        global sd_dp_all5: dis %6.3f `r(sd)' 
		
		qui sum `var' if q3<7
        global mean_dp_all6:dis %6.3f `r(mean)' 
        global sd_dp_all6: dis %6.3f `r(sd)' 
		
		qui sum `var' if imput_ols>6.91
        global mean_dp_all7:dis %6.3f `r(mean)' 
        global sd_dp_all7: dis %6.3f `r(sd)' 
		
		qui sum `var' if imput_ols<=6.91
        global mean_dp_all8:dis %6.3f `r(mean)' 
        global sd_dp_all8: dis %6.3f `r(sd)'
		
        forval i=1(2)3 {
                eststo col`i'_all1_`c_note': qui reg `var' ${speci`i'} if positionmapped=="partners", robust
                        if `i'<=2 {
                                estadd local l_fe "No", replace
                        }
                        else {
                                estadd local l_fe "Yes", replace
                        }
                        qui tab gp_id if _est_col`i'_all1_`c_note'
                        estadd local u_id `r(r)', replace
                        estadd local model_des "OLS"
                        estadd local mean $mean_dp_all1
                        estadd local sd $sd_dp_all1

				eststo col`i'_all2_`c_note': qui reg `var' ${speci`i'} if positionmapped== "board of directors", robust
                        if `i'<=2 {
                                estadd local l_fe "No", replace
                        }
                        else {
                                estadd local l_fe "Yes", replace
                        }
                        qui tab gp_id if _est_col`i'_all2_`c_note'
                        estadd local u_id `r(r)', replace
                        estadd local model_des "OLS"
                        estadd local mean $mean_dp_all2
                        estadd local sd $sd_dp_all2
						
				eststo col`i'_all3_`c_note': qui reg `var' ${speci`i'} if man_exe== 1 , robust
                        if `i'<=2 {
                                estadd local l_fe "No", replace
                        }
                        else {
                                estadd local l_fe "Yes", replace
                        }
                        qui tab gp_id if _est_col`i'_all3_`c_note'
                        estadd local u_id `r(r)', replace
                        estadd local model_des "OLS"
                        estadd local mean $mean_dp_all3
                        estadd local sd $sd_dp_all3
						
			  eststo col`i'_all4_`c_note': qui reg `var' ${speci`i'} if positionmapped== "others", robust
                        if `i'<=2 {
                                estadd local l_fe "No", replace
                        }
                        else {
                                estadd local l_fe "Yes", replace
                        }
                        qui tab gp_id if _est_col`i'_all4_`c_note'
                        estadd local u_id `r(r)', replace
                        estadd local model_des "OLS"
                        estadd local mean $mean_dp_all4
                        estadd local sd $sd_dp_all4
						
			 eststo col`i'_all5_`c_note': qui reg `var' ${speci`i'} if q3>=7, robust
                        if `i'<=2 {
                                estadd local l_fe "No", replace
                        }
                        else {
                                estadd local l_fe "Yes", replace
                        }
                        qui tab gp_id if _est_col`i'_all5_`c_note'
                        estadd local u_id `r(r)', replace
                        estadd local model_des "OLS"
                        estadd local mean $mean_dp_all5
                        estadd local sd $sd_dp_all5

				eststo col`i'_all6_`c_note': qui reg `var' ${speci`i'} if q3<7, robust
                        if `i'<=2 {
                                estadd local l_fe "No", replace
                        }
                        else {
                                estadd local l_fe "Yes", replace
                        }
                        qui tab gp_id if _est_col`i'_all6_`c_note'
                        estadd local u_id `r(r)', replace
                        estadd local model_des "OLS"
                        estadd local mean $mean_dp_all6
                        estadd local sd $sd_dp_all6
				  eststo col`i'_all7_`c_note': qui reg `var' ${speci`i'} if imput_ols>6.91, robust
                        if `i'<=2 {
                                estadd local l_fe "No", replace
                        }
                        else {
                                estadd local l_fe "Yes", replace
                        }
                        qui tab gp_id if _est_col`i'_all7_`c_note'
                        estadd local u_id `r(r)', replace
                        estadd local model_des "OLS"
                        estadd local mean $mean_dp_all7
                        estadd local sd $sd_dp_all7

				eststo col`i'_all8_`c_note': qui reg `var' ${speci`i'} if imput_ols<=6.91, robust
                        if `i'<=2 {
                                estadd local l_fe "No", replace
                        }
                        else {
                                estadd local l_fe "Yes", replace
                        }
                        qui tab gp_id if _est_col`i'_all8_`c_note'
                        estadd local u_id `r(r)', replace
                        estadd local model_des "OLS"
                        estadd local mean $mean_dp_all8
                        estadd local sd $sd_dp_all8
        }
}

**** two tables for different samples *******
esttab col1_all1_i col1_all2_i col1_all3_i col1_all4_i col1_all5_i col1_all6_i col1_all7_i col1_all8_i using "$appendixtable_dir/TableA14.tex", label booktabs eqlabels(none) replace ///
	star(* 0.1 ** 0.05 *** 0.01) t(%6.2f) b(%8.3f)  ///
        stats(N u_id r2 l_fe model_des mean sd,labels("Observations" "Unique GPs" "R-Squared"  "GP FEs" "Model" "DV Mean" "DV SD") fmt(a3 a3 %8.3f a3 a3 %6.3f %6.3f)) ///
	mtitle("Partner" "Director" "Manager" "Other""High" "Low""High" "Low" ) title("GP Preferences for LPs: Robustness Sample Spilts") ///
	drop(_cons) 
/*==============================================================================
Table A15. GP Preferences for LPs: Heterogeneity across Robustness Sample Spilts and Government Ownership
===============================================================================*/
use "$survey_dir/GP_reg_individual_character_hetero.dta", clear
drop if gp_id=="CAU"| gp_id=="FMZ" | gp_id=="OEJ"| gp_id=="QET"| gp_id=="QYN"| gp_id=="UTL"| gp_id=="UYM"| gp_id=="VUI"| gp_id=="XAJ"| gp_id=="XLJ"

	merge m:1 lp_profile_id using "$survey_dir/lp_profile_everyoption.dta", nogen keep(3)

    replace lp_ideology = 1 if stage_2 == 1
	replace lp_investment_stage = 0 if stage_2==1 | stage_5 == 1
	label var lp_investment_stage "Stage Focus"

	replace lp_aum = 0 if lp_aum<3
	replace lp_aum = 1 if lp_aum>=3 & !missing(lp_aum)
	label var lp_aum "Large Investor"
	
	**** relabeling ***
	label var lp_registered_cap_value "High Registered Capital"
	
	
******** gp choose lp regression *****
global mainvar lp_relation_gov lp_aum lp_registered_cap_value lp_industry lp_post_2010 lp_foreign_dummy lp_beijing_dummy lp_compliance lp_ideology lp_investment_stage 
global control1 lp_invest_restriction lp_top lp_team_connection lp_team_experience
global fe_model i.gp_fe

global speci1 $mainvar 
global speci2 $mainvar $control1
global speci3 $speci1 $fe_model	
global speci4 $speci2 $fe_model


gen gov_cri_1 = (gp_total_gov_share>=0 & !missing(gp_total_gov_share)) // many other gov definitions could be used here

*Partner Rating *
foreach var in q2 {
	if "`var'"=="q1" {
        	local c_note = "m"
        }
        else if "`var'" == "q2" {
        	local c_note = "i"
        }
        else {
        	local c_note = "a"
        }
        ************** gov-affiliated GP ******************
        qui sum `var' if positionmapped=="partners" & gov_cri_1==1
        global mean_dp_all1:dis %6.3f `r(mean)' 
        global sd_dp_all1: dis %6.3f `r(sd)' 
		
		qui sum `var' if positionmapped=="partners" & gov_cri_1==0
        global mean_dp_all11:dis %6.3f `r(mean)' 
        global sd_dp_all11: dis %6.3f `r(sd)' 
		
		qui sum `var' if positionmapped== "board of directors" & gov_cri_1==1
        global mean_dp_all2:dis %6.3f `r(mean)' 
        global sd_dp_all2: dis %6.3f `r(sd)' 
		
		qui sum `var' if positionmapped== "board of directors" & gov_cri_1==0
        global mean_dp_all21:dis %6.3f `r(mean)' 
        global sd_dp_all21: dis %6.3f `r(sd)' 
        
		qui sum `var' if man_exe== 1 & gov_cri_1==1
        global mean_dp_all3:dis %6.3f `r(mean)' 
        global sd_dp_all3: dis %6.3f `r(sd)' 
		
		qui sum `var' if man_exe== 1 & gov_cri_1==0
        global mean_dp_all31:dis %6.3f `r(mean)' 
        global sd_dp_all31: dis %6.3f `r(sd)' 
		
		qui sum `var' if positionmapped== "others" & gov_cri_1==1
        global mean_dp_all4:dis %6.3f `r(mean)' 
        global sd_dp_all4: dis %6.3f `r(sd)' 
		
		qui sum `var' if positionmapped== "others" & gov_cri_1==0
        global mean_dp_all41:dis %6.3f `r(mean)' 
        global sd_dp_all41: dis %6.3f `r(sd)' 
		
		qui sum `var' if gov_cri_1 == 1 & q3>=7
        global mean_dp_all5:dis %6.3f `r(mean)' 
        global sd_dp_all5: dis %6.3f `r(sd)' 
		
		qui sum `var' if gov_cri_1 == 0 & q3>=7 
        global mean_dp_all51:dis %6.3f `r(mean)' 
        global sd_dp_all51: dis %6.3f `r(sd)' 
		
		qui sum `var' if gov_cri_1 == 1 & q3<7
        global mean_dp_all6:dis %6.3f `r(mean)' 
        global sd_dp_all6: dis %6.3f `r(sd)' 
		
		qui sum `var' if gov_cri_1 == 0  & q3<7
        global mean_dp_all61:dis %6.3f `r(mean)' 
        global sd_dp_all61: dis %6.3f `r(sd)' 
		
		qui sum `var' if gov_cri_1 == 1 & imput_ols>6.91
        global mean_dp_all7:dis %6.3f `r(mean)' 
        global sd_dp_all7: dis %6.3f `r(sd)' 
		
		qui sum `var' if gov_cri_1 == 0 & imput_ols>6.91 
        global mean_dp_all71:dis %6.3f `r(mean)' 
        global sd_dp_all71: dis %6.3f `r(sd)' 
		
		qui sum `var' if gov_cri_1 == 1 & imput_ols<=6.91
        global mean_dp_all8:dis %6.3f `r(mean)' 
        global sd_dp_all8: dis %6.3f `r(sd)' 
		
		qui sum `var' if gov_cri_1 == 0  & imput_ols<=6.91
        global mean_dp_all81:dis %6.3f `r(mean)' 
        global sd_dp_all81: dis %6.3f `r(sd)' 
		
        foreach i of numlist 1 {
                eststo col`i'_all1_`c_note': qui reg `var' ${speci`i'} if positionmapped=="partners" & gov_cri_1==1, robust
                        if `i'<=2 {
                                estadd local l_fe "No", replace
                        }
                        else {
                                estadd local l_fe "Yes", replace
                        }
                        qui tab gp_id if _est_col`i'_all1_`c_note'
                        estadd local u_id `r(r)', replace
                        estadd local model_des "OLS"
                        estadd local mean $mean_dp_all1
                        estadd local sd $sd_dp_all1
				
				eststo col`i'_all11_`c_note': qui reg `var' ${speci`i'} if positionmapped=="partners" & gov_cri_1==0, robust
                        if `i'<=2 {
                                estadd local l_fe "No", replace
                        }
                        else {
                                estadd local l_fe "Yes", replace
                        }
                        qui tab gp_id if _est_col`i'_all11_`c_note'
                        estadd local u_id `r(r)', replace
                        estadd local model_des "OLS"
                        estadd local mean $mean_dp_all11
                        estadd local sd $sd_dp_all11

				eststo col`i'_all2_`c_note': qui reg `var' ${speci`i'} if positionmapped== "board of directors" & gov_cri_1==1, robust
                        if `i'<=2 {
                                estadd local l_fe "No", replace
                        }
                        else {
                                estadd local l_fe "Yes", replace
                        }
                        qui tab gp_id if _est_col`i'_all2_`c_note'
                        estadd local u_id `r(r)', replace
                        estadd local model_des "OLS"
                        estadd local mean $mean_dp_all2
                        estadd local sd $sd_dp_all2
						
				eststo col`i'_all21_`c_note': qui reg `var' ${speci`i'} if positionmapped== "board of directors" & gov_cri_1==0, robust
                        if `i'<=2 {
                                estadd local l_fe "No", replace
                        }
                        else {
                                estadd local l_fe "Yes", replace
                        }
                        qui tab gp_id if _est_col`i'_all21_`c_note'
                        estadd local u_id `r(r)', replace
                        estadd local model_des "OLS"
                        estadd local mean $mean_dp_all21
                        estadd local sd $sd_dp_all21
						
				eststo col`i'_all3_`c_note': qui reg `var' ${speci`i'} if man_exe== 1 & gov_cri_1==1, robust
                        if `i'<=2 {
                                estadd local l_fe "No", replace
                        }
                        else {
                                estadd local l_fe "Yes", replace
                        }
                        qui tab gp_id if _est_col`i'_all3_`c_note'
                        estadd local u_id `r(r)', replace
                        estadd local model_des "OLS"
                        estadd local mean $mean_dp_all3
                        estadd local sd $sd_dp_all3
						
				eststo col`i'_all31_`c_note': qui reg `var' ${speci`i'} if man_exe== 1 & gov_cri_1==0, robust
                        if `i'<=2 {
                                estadd local l_fe "No", replace
                        }
                        else {
                                estadd local l_fe "Yes", replace
                        }
                        qui tab gp_id if _est_col`i'_all31_`c_note'
                        estadd local u_id `r(r)', replace
                        estadd local model_des "OLS"
                        estadd local mean $mean_dp_all31
                        estadd local sd $sd_dp_all31
						
			  eststo col`i'_all4_`c_note': qui reg `var' ${speci`i'} if positionmapped== "others" & gov_cri_1==1, robust
                        if `i'<=2 {
                                estadd local l_fe "No", replace
                        }
                        else {
                                estadd local l_fe "Yes", replace
                        }
                        qui tab gp_id if _est_col`i'_all4_`c_note'
                        estadd local u_id `r(r)', replace
                        estadd local model_des "OLS"
                        estadd local mean $mean_dp_all4
                        estadd local sd $sd_dp_all4
						
			eststo col`i'_all41_`c_note': qui reg `var' ${speci`i'} if positionmapped== "others" & gov_cri_1==0, robust
                        if `i'<=2 {
                                estadd local l_fe "No", replace
                        }
                        else {
                                estadd local l_fe "Yes", replace
                        }
                        qui tab gp_id if _est_col`i'_all41_`c_note'
                        estadd local u_id `r(r)', replace
                        estadd local model_des "OLS"
                        estadd local mean $mean_dp_all41
                        estadd local sd $sd_dp_all41
			
			 eststo col`i'_all5_`c_note': qui reg `var' ${speci`i'} if gov_cri_1==1& q3>=7, robust
                        if `i'<=2 {
                                estadd local l_fe "No", replace
                        }
                        else {
                                estadd local l_fe "Yes", replace
                        }
                        qui tab gp_id if _est_col`i'_all5_`c_note'
                        estadd local u_id `r(r)', replace
                        estadd local model_des "OLS"
                        estadd local mean $mean_dp_all5
                        estadd local sd $sd_dp_all5

				eststo col`i'_all51_`c_note': qui reg `var' ${speci`i'} if gov_cri_1==0& q3>=7, robust
                        if `i'<=2 {
                                estadd local l_fe "No", replace
                        }
                        else {
                                estadd local l_fe "Yes", replace
                        }
                        qui tab gp_id if _est_col`i'_all51_`c_note'
                        estadd local u_id `r(r)', replace
                        estadd local model_des "OLS"
                        estadd local mean $mean_dp_all51
                        estadd local sd $sd_dp_all51
						
				eststo col`i'_all6_`c_note': qui reg `var' ${speci`i'} if gov_cri_1==1& q3<7, robust
                        if `i'<=2 {
                                estadd local l_fe "No", replace
                        }
                        else {
                                estadd local l_fe "Yes", replace
                        }
                        qui tab gp_id if _est_col`i'_all6_`c_note'
                        estadd local u_id `r(r)', replace
                        estadd local model_des "OLS"
                        estadd local mean $mean_dp_all6
                        estadd local sd $sd_dp_all6

				eststo col`i'_all61_`c_note': qui reg `var' ${speci`i'} if gov_cri_1==0& q3<7, robust
                        if `i'<=2 {
                                estadd local l_fe "No", replace
                        }
                        else {
                                estadd local l_fe "Yes", replace
                        }
                        qui tab gp_id if _est_col`i'_all61_`c_note'
                        estadd local u_id `r(r)', replace
                        estadd local model_des "OLS"
                        estadd local mean $mean_dp_all61
                        estadd local sd $sd_dp_all61
						
				eststo col`i'_all7_`c_note': qui reg `var' ${speci`i'} if gov_cri_1==1& imput_ols>6.91, robust
                        if `i'<=2 {
                                estadd local l_fe "No", replace
                        }
                        else {
                                estadd local l_fe "Yes", replace
                        }
                        qui tab gp_id if _est_col`i'_all1_`c_note'
                        estadd local u_id `r(r)', replace
                        estadd local model_des "OLS"
                        estadd local mean $mean_dp_all7
                        estadd local sd $sd_dp_all7

				eststo col`i'_all71_`c_note': qui reg `var' ${speci`i'} if gov_cri_1==0& imput_ols>6.91, robust
                        if `i'<=2 {
                                estadd local l_fe "No", replace
                        }
                        else {
                                estadd local l_fe "Yes", replace
                        }
                        qui tab gp_id if _est_col`i'_all11_`c_note'
                        estadd local u_id `r(r)', replace
                        estadd local model_des "OLS"
                        estadd local mean $mean_dp_all71
                        estadd local sd $sd_dp_all71
						
				eststo col`i'_all8_`c_note': qui reg `var' ${speci`i'} if gov_cri_1==1& imput_ols<=6.91, robust
                        if `i'<=2 {
                                estadd local l_fe "No", replace
                        }
                        else {
                                estadd local l_fe "Yes", replace
                        }
                        qui tab gp_id if _est_col`i'_all8_`c_note'
                        estadd local u_id `r(r)', replace
                        estadd local model_des "OLS"
                        estadd local mean $mean_dp_all8
                        estadd local sd $sd_dp_all8

				eststo col`i'_all81_`c_note': qui reg `var' ${speci`i'} if gov_cri_1==0& imput_ols<=6.91, robust
                        if `i'<=2 {
                                estadd local l_fe "No", replace
                        }
                        else {
                                estadd local l_fe "Yes", replace
                        }
                        qui tab gp_id if _est_col`i'_all81_`c_note'
                        estadd local u_id `r(r)', replace
                        estadd local model_des "OLS"
                        estadd local mean $mean_dp_all81
                        estadd local sd $sd_dp_all81
        }
}

**** two tables for different samples *******
esttab col1_all1_i col1_all11_i col1_all2_i col1_all21_i col1_all3_i col1_all31_i col1_all4_i col1_all41_i col1_all5_i col1_all51_i col1_all6_i col1_all61_i col1_all7_i col1_all71_i col1_all8_i col1_all81_i  using "$appendixtable_dir/TableA15.tex", label booktabs eqlabels(none) replace ///
	star(* 0.1 ** 0.05 *** 0.01) t(%6.2f) b(%8.3f)  ///
        stats(N u_id r2 l_fe model_des mean sd,labels("Observations" "Unique GPs" "R-Squared"  "GP FEs" "Model" "DV Mean" "DV SD") fmt(a3 a3 %8.3f a3 a3 %6.3f %6.3f)) ///
	mtitle("Gov" "Non-Gov" "Gov" "Non-Gov""Gov" "Non-Gov" "Gov" "Non-Gov" "Gov" "Non-Gov" "Gov" "Non-Gov""Gov" "Non-Gov" "Gov" "Non-Gov") title("GP Preferences for LPs: Heterogeneity across Robustness Sample Spilts and Government Ownership") ///
	drop( _cons) 

/*==============================================================================
Table A16. Variables in Synthetic GP Profiles
Table A17. Description of GP Profiles Randomized Components
	no code
===============================================================================*/

		
/*==============================================================================
Table A18. LP Preferences for GPs, expected interest
===============================================================================*/
use "$survey_dir/lp_survey_data_regress.dta", clear

	drop if lp_id == "MLD"

	merge m:1 gp_profile_id using "$survey_dir/gp_profile_everyoption.dta", nogen keep(3)
	
***** regrouping and relabelling ****
label var gp_fund "Serial Fund Manager"
replace gp_fund = 1 if gp_fund>0 


label var gp_invest "Exits"
replace gp_invest = 0 if invest_1 == 1 | invest_5 == 1
replace gp_invest = 1 if invest_2==1 | invest_3==1 | invest_4==1 | invest_6==1 | invest_7==1 | invest_8==1

label var gp_irr "High IRR"
replace gp_irr = 1 if irr_5 ==1  | irr_6 ==1 | irr_7==1 | irr_8==1
replace gp_irr = 0 if irr_1 == 1 | irr_2==1 | irr_3==1 | irr_4==1

label var gp_aum "High AUM"
replace gp_aum = 0 if gp_aum<2
replace gp_aum = 1 if gp_aum>=2 & !missing(gp_aum)

label var gp_vcpe "VC"
label var gp_top "Ranked GP"

replace gp_relation_gov = 1 if relation_gov_1 == 1 | relation_gov_2 == 1
replace gp_relation_gov = 0 if relation_gov_3 == 1 

****** LP choose GP regression ****
/* set specifications first */
global mainvar gp_relation_gov
global control1 gp_team_connection gp_team_experience gp_aum gp_irr gp_invest gp_top gp_industry gp_post_2010 gp_foreign_dummy gp_beijing_dummy gp_vcpe 
global control2 gp_market gp_ideology gp_have_stage gp_invest_horizon gp_fund  
global fe_model i.lp_fe


global speci3 $mainvar $control1 $control2
global speci6 $speci3 $fe_model
  
/* Expected interest */

qui sum q3
local mean_dp: dis %6.3f `r(mean)'
local sd_dp: dis %6.3f `r(sd)'

forval i=3(3)6 {
	eststo col`i'_e: qui reg q3 ${speci`i'}, robust
                if `i'<=3 {
                        estadd local l_fe "No", replace
                }
                else {
                	estadd local l_fe "Yes", replace
                }
                qui tab lp_id if _est_col`i'_e
                estadd local u_id `r(r)', replace
                estadd local model_des "OLS"
                estadd local mean `mean_dp'
                estadd local sd `sd_dp'       
}

esttab col3_e col6_e using "$appendixtable_dir/TableA18.tex", label booktabs eqlabels(none) replace ///
	star(* 0.1 ** 0.05 *** 0.01) t(%6.2f) b(%8.3f)  ///
        stats(N u_id r2 l_fe model_des mean sd,labels("Observations" "Unique LPs" "R-Squared"  "LP FEs" "Model" "DV Mean" "DV SD") fmt(a3 a3 %8.3f a3 a3 %6.3f %6.3f)) ///
	mtitle("Expected" "Interest") title("LP Preferences for GPs:Expected Interest") ///
	drop(*lp_fe _cons)  
	
	

/*==============================================================================
Table A19. LP Preferences for GPs (Ordered Probit)
===============================================================================*/
use "$survey_dir/lp_survey_data_regress.dta", clear

	drop if lp_id == "MLD"

	merge m:1 gp_profile_id using "$survey_dir/gp_profile_everyoption.dta", nogen keep(3)
	
***** regrouping and relabelling ****
label var gp_fund "Serial Fund Manager"
replace gp_fund = 1 if gp_fund>0 


label var gp_invest "Exits"
replace gp_invest = 0 if invest_1 == 1 | invest_5 == 1
replace gp_invest = 1 if invest_2==1 | invest_3==1 | invest_4==1 | invest_6==1 | invest_7==1 | invest_8==1

label var gp_irr "High IRR"
replace gp_irr = 1 if irr_5 ==1  | irr_6 ==1 | irr_7==1 | irr_8==1
replace gp_irr = 0 if irr_1 == 1 | irr_2==1 | irr_3==1 | irr_4==1

label var gp_aum "High AUM"
replace gp_aum = 0 if gp_aum<2
replace gp_aum = 1 if gp_aum>=2 & !missing(gp_aum)

label var gp_vcpe "VC"
label var gp_top "Ranked GP"

replace gp_relation_gov = 1 if relation_gov_1 == 1 | relation_gov_2 == 1
replace gp_relation_gov = 0 if relation_gov_3 == 1 

****** LP choose GP regression ****
/* set specifications first */
global mainvar gp_relation_gov
global control1 gp_team_connection gp_team_experience gp_aum gp_irr gp_invest gp_top gp_industry gp_post_2010 gp_foreign_dummy gp_beijing_dummy gp_vcpe 
global control2 gp_market gp_ideology gp_have_stage gp_invest_horizon gp_fund  
global fe_model i.lp_fe


global speci3 $mainvar $control1 $control2
global speci6 $speci3 $fe_model

****************************************************************************

*** reg of Partner Rating (q2) ***
qui sum q2
local mean_dp: dis %6.3f `r(mean)'
local sd_dp: dis %6.3f `r(sd)'

	* reg of Partner Rating (q2), without FEs
	eststo col3_c:  oprobit q2 ${speci3}, robust      
        estadd local l_fe "No", replace
        qui tab lp_id if _est_col3_c
        estadd local u_id `r(r)', replace
        estadd local model_des "OLS"
        estadd local mean `mean_dp'
        estadd local sd `sd_dp'  

	* reg of Partner Rating (q2), with FEs
	eststo col6_c:  oprobit q2 ${speci6}, robust
       estadd local l_fe "Yes", replace
       qui tab lp_id if _est_col6_c
       estadd local u_id `r(r)', replace
       estadd local model_des "OLS"
       estadd local mean `mean_dp'
       estadd local sd `sd_dp'  
	

esttab col3_c col6_c using "$appendixtable_dir/TableA19.tex", label booktabs eqlabels(none) replace ///
	star(* 0.1 ** 0.05 *** 0.01) t(%6.2f) b(%8.3f)  ///
        stats(N u_id r2 l_fe model_des mean sd,labels("Observations" "Unique LPs" "R-Squared"  "LP FEs" "Model" "DV Mean" "DV SD") fmt(a3 a3 %8.3f a3 a3 %6.3f %6.3f)) ///
	mtitle("Partner" "Rating") title("LP Preferences for GPs (Ordered Probit)") ///
	drop(*lp_fe)  
	
	
/*==============================================================================
Table A20. LP Preferences for GPs: Clustering SEs at Respondent Level
===============================================================================*/
use "$survey_dir/lp_survey_data_regress.dta", clear

	merge m:1 gp_profile_id using "$survey_dir/gp_profile_everyoption.dta", nogen keep(3)
	
***** regrouping and relabelling ****
label var gp_fund "Serial Fund Manager"
replace gp_fund = 1 if gp_fund>0 


label var gp_invest "Exits"
replace gp_invest = 0 if invest_1 == 1 | invest_5 == 1
replace gp_invest = 1 if invest_2==1 | invest_3==1 | invest_4==1 | invest_6==1 | invest_7==1 | invest_8==1

label var gp_irr "High IRR"
replace gp_irr = 1 if irr_5 ==1  | irr_6 ==1 | irr_7==1 | irr_8==1
replace gp_irr = 0 if irr_1 == 1 | irr_2==1 | irr_3==1 | irr_4==1

label var gp_aum "High AUM"
replace gp_aum = 0 if gp_aum<2
replace gp_aum = 1 if gp_aum>=2 & !missing(gp_aum)

label var gp_vcpe "VC"

replace gp_relation_gov = 1 if relation_gov_1 == 1 | relation_gov_2 == 1
replace gp_relation_gov = 0 if relation_gov_3 == 1 

****** LP choose GP regression ****
/* set specifications first */
global mainvar gp_relation_gov
global control1 gp_team_connection gp_team_experience gp_aum gp_irr gp_invest gp_top gp_industry gp_post_2010 gp_foreign_dummy gp_beijing_dummy gp_vcpe 
global control2 gp_market gp_ideology gp_have_stage gp_invest_horizon gp_fund  
global fe_model i.lp_fe


global speci3 $mainvar $control1 $control2
global speci6 $speci3 $fe_model



global speci3 $mainvar $control1 $control2
global speci6 $speci3 $fe_model

/*==============================
Partner Grading
================================*/

qui sum q2
local mean_dp: dis %6.3f `r(mean)'
local sd_dp: dis %6.3f `r(sd)'

forval i=3(3)6 {
	eststo col`i'_c: qui reg q2 ${speci`i'}, vce(cluster lp_id)
                if `i'<=3 {
                        estadd local l_fe "No", replace
                }
                else {
                	estadd local l_fe "Yes", replace
                }
                qui tab lp_id if _est_col`i'_c
                estadd local u_id `r(r)', replace
                estadd local model_des "OLS"
                estadd local mean `mean_dp'
                estadd local sd `sd_dp'       
}

esttab col3_c col6_c using "$appendixtable_dir/TableA20.tex", label booktabs eqlabels(none) replace ///
	star(* 0.1 ** 0.05 *** 0.01) t(%6.2f) b(%8.3f)  ///
        stats(N u_id r2 l_fe model_des mean sd,labels("Observations" "Unique LPs" "R-Squared"  "LP FEs" "Model" "DV Mean" "DV SD") fmt(a3 a3 %8.3f a3 a3 %6.3f %6.3f)) ///
	mtitle("Partner" "Rating") title("LP Preferences for GPs: Clustering SEs at Respondent Level") ///
	drop(*lp_fe _cons)  


/*==============================================================================
Table A21. LP Preferences for GPs: Heterogeneity by Government-Owned LPs
===============================================================================*/
use "$survey_dir/lp_survey_data_regress.dta", clear

	drop if lp_id == "MLD"

	merge m:1 gp_profile_id using "$survey_dir/gp_profile_everyoption.dta", nogen keep(3)
	
***** regrouping and relabelling ****
label var gp_fund "Serial Fund Manager"
replace gp_fund = 1 if gp_fund>0 


label var gp_invest "Exits"
replace gp_invest = 0 if invest_1 == 1 | invest_5 == 1
replace gp_invest = 1 if invest_2==1 | invest_3==1 | invest_4==1 | invest_6==1 | invest_7==1 | invest_8==1

label var gp_irr "High IRR"
replace gp_irr = 1 if irr_5 ==1  | irr_6 ==1 | irr_7==1 | irr_8==1
replace gp_irr = 0 if irr_1 == 1 | irr_2==1 | irr_3==1 | irr_4==1

label var gp_aum "High AUM"
replace gp_aum = 0 if gp_aum<2
replace gp_aum = 1 if gp_aum>=2 & !missing(gp_aum)

label var gp_vcpe "VC"
label var gp_top "Ranked GP"

replace gp_relation_gov = 1 if relation_gov_1 == 1 | relation_gov_2 == 1
replace gp_relation_gov = 0 if relation_gov_3 == 1 

****** LP choose GP regression ****
/* set specifications first */
global mainvar gp_relation_gov
global control1 gp_team_connection gp_team_experience gp_aum gp_irr gp_invest gp_top gp_industry gp_post_2010 gp_foreign_dummy gp_beijing_dummy gp_vcpe 
global control2 gp_market gp_ideology gp_have_stage gp_invest_horizon gp_fund  
global fe_model i.lp_fe


global speci3 $mainvar $control1 $control2
global speci6 $speci3 $fe_model


  
/*==============================
Partner Grading
================================*/



forval i = 0/0 {
	gen gov_cri_`i'= ((lp_total_gov_share>= 10* `i' & !missing(lp_total_gov_share))|lptype_en=="Government Bureau"|lptype_en=="Government Guide Fund")
}

forval j = 0/0 {
	qui sum q2
	local mean_dp: dis %6.3f `r(mean)'
	local sd_dp: dis %6.3f `r(sd)'
	forval i=3(3)6 {
		eststo col`i'_`j'_c_1: qui reg q2 ${speci`i'} if gov_cri_`j' == 1, robust
					if `i'<=3 {
							estadd local l_fe "No", replace
					}
					else {
						estadd local l_fe "Yes", replace
					}
					qui tab lp_id if _est_col`i'_`j'_c_1
					estadd local u_id `r(r)', replace
					estadd local model_des "OLS"
					estadd local mean `mean_dp'
					estadd local sd `sd_dp'       
		
		eststo col`i'_`j'_c_0: qui reg q2 ${speci`i'} if gov_cri_`j' == 0, robust
					if `i'<=3 {
							estadd local l_fe "No", replace
					}
					else {
						estadd local l_fe "Yes", replace
					}
					qui tab lp_id if _est_col`i'_`j'_c_0
					estadd local u_id `r(r)', replace
					estadd local model_des "OLS"
					estadd local mean `mean_dp'
					estadd local sd `sd_dp'       
	}
	esttab col3_`j'_c_1 col3_`j'_c_0 col6_`j'_c_1 col6_`j'_c_0   using "$appendixtable_dir/TableA21_regression", label booktabs eqlabels(none) replace ///
	star(* 0.1 ** 0.05 *** 0.01) t(%6.2f) b(%8.3f)  ///
        stats(N u_id r2 l_fe model_des mean sd,labels("Observations" "Unique LPs" "R-Squared"  "LP FEs" "Model" "DV Mean" "DV SD") fmt(a3 a3 %8.3f a3 a3 %6.3f %6.3f)) ///
	mtitle("Gov" "Non-Gov" "Gov" "Non-Gov") title("LP Preferences for GPs: Heterogeneity by Government-Owned LPs") ///
	drop(*lp_fe _cons)  

**** test coefficient ****
bysort lp_fe: center q1 q2 q3, prefix(cy_)
bysort lp_fe: center $speci3, prefix(cx_)

	foreach var in q2 {
	if "`var'"=="q1" {
        	local c_note = "m"
        }
        else if "`var'" == "q2" {
        	local c_note = "i"
        }
        else {
        	local c_note = "a"
        }
		************** gov-affiliated LP ******************
        eststo col3_all_`c_note': qui reg `var' $speci3 if gov_cri_`j'==1
        eststo col6_all_`c_note': qui reg cy_`var' cx_* if gov_cri_`j'==1
       
        ****** non gov-affiliated LP *****
        eststo col3_all_n_`c_note': qui reg `var' $speci3 if gov_cri_`j'==0
        eststo col6_all_n_`c_note': qui reg cy_`var' cx_* if gov_cri_`j'==0

        ***** generate the estimator comparison for two groups for the same dep var ****
        
        ***** all sample ***
        eststo com1_all_`c_note': qui suest col3_all_`c_note' col3_all_n_`c_note', vce(robust)
        foreach var in $speci3 {
                qui test [col3_all_`c_note'_mean]`var'=[col3_all_n_`c_note'_mean]`var'
                estadd scalar `var' = r(p)
                
        }
        estadd local l_fe "No" 

        eststo com2_all_`c_note': qui suest col6_all_`c_note' col6_all_n_`c_note', vce(robust)
        foreach var in $speci3 {
                qui test [col6_all_`c_note'_mean]cx_`var'=[col6_all_n_`c_note'_mean]cx_`var'
                estadd scalar `var' = r(p)        
        }
        estadd local l_fe "Yes"        
    }
	esttab com1_all_i com2_all_i using "$appendixtable_dir/TableA21_SURtest.tex", label booktabs eqlabels(none) replace stats($speci3 l_fe,  label("Government Investors" "Team Government Experience" "Team Industry Experience" "High AUM" "High IRR" "Exits" "Ranked GP" "Industry Information" "Young GP" "Headquarter In Foreign Country" "Headquarter In Beijing" "VC" "Market Approach" "Investment Philosophy" "Investment Stage" "Investment Horizon" "Serial Fund Manager" "GP FEs") fmt(%8.3f %8.3f %8.3f %8.3f %8.3f %8.3f %8.3f %8.3f %8.3f %8.3f %8.3f %8.3f %8.3f %8.3f %8.3f %8.3f %8.3f a3)) ///
	mtitle("P-Value" "P-Value") title("Difference in Coefficients (p-value) Gov VS Non-Gov (Full Sample)") drop(*)

	

}

**** to form the final table, use a simple Python code to transform the latex files （text_gene.py）***

/*==============================================================================
Table A22. GP Preferences for LPs: Heterogeneity by Government-Owned GPs and across Government Levels
===============================================================================*/
use "$survey_dir/gp_survey_data_regress.dta", clear

	drop if gp_id=="CAU"| gp_id=="FMZ" | gp_id=="OEJ"| gp_id=="QET"| gp_id=="QYN"| gp_id=="UTL"| gp_id=="UYM"| gp_id=="VUI"| gp_id=="XAJ"| gp_id=="XLJ"

	merge m:1 lp_profile_id using "$survey_dir/lp_profile_everyoption.dta", nogen keep(3)
	
	****** regrouping effort 1 ****
	replace lp_ideology = 1 if stage_2 == 1
	replace lp_investment_stage = 0 if stage_2==1 | stage_5 == 1
	
	label var lp_investment_stage "Stage Focus"
	
	**** regrouping effort 2 ****
	label var lp_invest_restriction "GGF Extra Details"
	
	***** regrouping effort 3 *****
	replace lp_aum = 0 if lp_aum<3
	replace lp_aum = 1 if lp_aum>=3 & !missing(lp_aum)
	label var lp_aum "Large Investor"
	
	gen govties_central = (relation_5==1)
	gen govties_provincial = (relation_6==1 | relation_7==1 | relation_8==1 | relation_9==1)
	gen govties_local = (relation_10==1 | relation_11==1)
	
	label var govties_central "GovTies-Central"
	label var govties_provincial "GovTies-Provincial"
	label var govties_local "GovTies-Local"
	
	**** relabeling ***
	label var lp_registered_cap_value "High Registered Capital"
	
	forvalues num = 1/11{
		label var relation_`num' "Gov Ties Option `num'"
	}
	
******** gp choose lp regression *****
global mainvar govties_central govties_provincial govties_local lp_aum lp_registered_cap_value lp_industry lp_post_2010 lp_foreign_dummy lp_beijing_dummy lp_compliance lp_ideology lp_investment_stage 
global control1 lp_invest_restriction lp_top lp_team_connection lp_team_experience
global fe_model i.gp_fe

global speci1 $mainvar 
global speci2 $mainvar $control1
global speci3 $speci1 $fe_model	
global speci4 $speci2 $fe_model


gen gov_cri_1 = (gp_total_gov_share>=0 & !missing(gp_total_gov_share)) // many other gov definitions could be used here

*Partner Rating *
foreach var in q2 {
	if "`var'"=="q1" {
        	local c_note = "m"
        }
        else if "`var'" == "q2" {
        	local c_note = "i"
        }
        else {
        	local c_note = "a"
        }
        ************** gov-affiliated GP ******************
        qui sum `var' if gov_cri_1 == 1
        global mean_dp_all:dis %6.3f `r(mean)' 
        global sd_dp_all: dis %6.3f `r(sd)' 
		
		qui sum `var' if gov_cri_1 == 0 
        global mean_dp_full:dis %6.3f `r(mean)' 
        global sd_dp_full: dis %6.3f `r(sd)' 

        forval i=1(2)3 {
                eststo col`i'_all_`c_note': qui reg `var' ${speci`i'} if gov_cri_1==1, robust
                        if `i'<=2 {
                                estadd local l_fe "No", replace
                        }
                        else {
                                estadd local l_fe "Yes", replace
                        }
                        qui tab gp_id if _est_col`i'_all_`c_note'
                        estadd local u_id `r(r)', replace
                        estadd local model_des "OLS"
                        estadd local mean $mean_dp_all
                        estadd local sd $sd_dp_all

				eststo col`i'_full_`c_note': qui reg `var' ${speci`i'} if gov_cri_1==0, robust
                        if `i'<=2 {
                                estadd local l_fe "No", replace
                        }
                        else {
                                estadd local l_fe "Yes", replace
                        }
                        qui tab gp_id if _est_col`i'_full_`c_note'
                        estadd local u_id `r(r)', replace
                        estadd local model_des "OLS"
                        estadd local mean $mean_dp_full
                        estadd local sd $sd_dp_full
        }
}


**** two tables for different samples *******
esttab col1_all_i col1_full_i col3_all_i col3_full_i using "$appendixtable_dir/TableA22_regression.tex", label booktabs eqlabels(none) replace ///
	star(* 0.1 ** 0.05 *** 0.01) t(%6.2f) b(%8.3f)  ///
        stats(N u_id r2 l_fe model_des mean sd,labels("Observations" "Unique GPs" "R-Squared"  "GP FEs" "Model" "DV Mean" "DV SD") fmt(a3 a3 %8.3f a3 a3 %6.3f %6.3f)) ///
	mtitle("Gov" "Non-Gov" "Gov" "Non-Gov") title("GP Preferences for LPs: Heterogeneity by Government-Owned GPs and across Government Levels") ///
	drop(*gp_fe _cons) 

**** test coefficient ****
bysort gp_fe: center q1 q2 q3, prefix(cy_)
bysort gp_fe: center $speci1, prefix(cx_)
*** gov_affiliated GP vs non_gov_affiliated GP ***
*Cooperation Interest (Meeting Dummy) Partner Grading  Expected Interests  for different samples*
foreach var in q2 {
	if "`var'"=="q1" {
        	local c_note = "m"
        }
        else if "`var'" == "q2" {
        	local c_note = "i"
        }
        else {
        	local c_note = "a"
        }
	************** gov-affiliated GP ******************
        eststo col3_all_`c_note': qui reg `var' $speci1 if gov_cri_1==1
        eststo col6_all_`c_note': qui reg cy_`var' cx_* if gov_cri_1==1
       
        ****** non gov-affiliated GP *****
        eststo col3_all_n_`c_note': qui reg `var' $speci1 if gov_cri_1==0
        eststo col6_all_n_`c_note': qui reg cy_`var' cx_* if gov_cri_1==0

        ***** generate the estimator comparison for two groups for the same dep var ****
        
        ***** all sample ***
        eststo com1_all_`c_note': qui suest col3_all_`c_note' col3_all_n_`c_note', vce(robust)
        foreach var in $speci1 {
                qui test [col3_all_`c_note'_mean]`var'=[col3_all_n_`c_note'_mean]`var'
                estadd scalar `var' = r(p)
                
        }
        estadd local l_fe "No" 

        eststo com2_all_`c_note': qui suest col6_all_`c_note' col6_all_n_`c_note', vce(robust)
        foreach var in $speci1 {
                qui test [col6_all_`c_note'_mean]cx_`var'=[col6_all_n_`c_note'_mean]cx_`var'
                estadd scalar `var' = r(p)        
        }
        estadd local l_fe "Yes" 
        
        
}

esttab com1_all_i com2_all_i using "$appendixtable_dir/TableA22_SURtest.tex", label booktabs eqlabels(none) replace stats($speci1 l_fe, label("govties_central" "govties_provincial" "govties_local" "Large Investor" "High Registered Capital" "Industry Information" "Young LP" "Headquarter In Foreign Country" "Headquarter In Beijing" "Corporate Governance" "Investment Philosophy" "Stage Focus" "GP FEs") fmt(%8.3f %8.3f %8.3f %8.3f %8.3f %8.3f %8.3f %8.3f %8.3f %8.3f %8.3f %8.3f %8.3f %8.3f %8.3f %8.3f %8.3f %8.3f %8.3f %8.3f %8.3f a3)) ///
        mtitle("P-Value" "P-Value") title("Difference in Coefficients (p-value) Gov VS Non-Gov (Full Sample)") drop(*)

eststo clear

**** to form the final table, use a simple Python code to transform the latex files （text_gene.py）***
/*==============================================================================
Table A23. GP Preferences for LPs: Heterogeneity by Respondent Type
===============================================================================*/
***** get performance variables *****
use "$zero2ipo_dir/GP_performance_details.dta", clear

	keep GP_fullname gp_comprehensive_return	
	ren *, lower
	merge 1:m gp_fullname using "$survey_dir/gp_survey_data_regress.dta", nogen keep(3)
	
	keep gp_fullname gp_comprehensive_return
	duplicates drop
	*** get median comprehensive return for quality measures
	qui sum gp_comprehensive_return, de
	global med_cr2 = `r(p50)'
	
	tempfile gp_perform
	save `gp_perform'

********************************* regression tables ****************************************
use "$survey_dir/gp_survey_data_regress.dta", clear

	drop if gp_id=="CAU"| gp_id=="FMZ" | gp_id=="OEJ"| gp_id=="QET"| gp_id=="QYN"| gp_id=="UTL"| gp_id=="UYM"| gp_id=="VUI"| gp_id=="XAJ"| gp_id=="XLJ"

	merge m:1 lp_profile_id using "$survey_dir/lp_profile_everyoption.dta", nogen keep(3)
	merge m:1 gp_fullname using `gp_perform', nogen keep(3)

	****** regrouping effort 1 ****
	replace lp_ideology = 1 if stage_2 == 1
	replace lp_investment_stage = 0 if stage_2==1 | stage_5 == 1
	
	label var lp_investment_stage "Stage Focus"
	
	**** regrouping effort 2 ****
	label var lp_invest_restriction "GGF Extra Details"
	
	***** regrouping effort 3 *****
	replace lp_aum = 0 if lp_aum<3
	replace lp_aum = 1 if lp_aum>=3 & !missing(lp_aum)
	label var lp_aum "Large Investor"
	
	**** relabeling ***
	label var lp_registered_cap_value "High Registered Capital"
	
	
******** gp choose lp regression (set variables) *****
global mainvar lp_relation_gov lp_aum lp_registered_cap_value lp_industry lp_post_2010 lp_foreign_dummy lp_beijing_dummy lp_compliance lp_ideology lp_investment_stage 
global leave1main lp_aum lp_registered_cap_value lp_industry lp_post_2010 lp_foreign_dummy lp_beijing_dummy lp_compliance lp_ideology lp_investment_stage

******** generate gov and quality dummy ********
gen gov_cri_1 = (gp_total_gov_share>=0 & !missing(gp_total_gov_share)) // many other gov definitions could be used here

**** quality measure
gen gpabovemedian = (gp_comprehensive_return>=$med_cr2 & !missing(gp_comprehensive_return))
*** also, if top ranked, take it as high quality ***
replace gpabovemedian = (gp_topranked==1) if gpabovemedian == 0 

label var gov_cri_1 "Gov GP"
label var gpabovemedian "High Quality GP"


***** see immediate regression results, use the commands below *****
reg q2 $leave1main gov_cri_1#gpabovemedian#lp_relation_gov, robust
reg q3 $leave1main gov_cri_1#gpabovemedian#lp_relation_gov, robust
/*===================================
section for generating latex table 
=====================================*/
foreach var in q2 {
	if "`var'"=="q1" {
        	local c_note = "m"
        }
        else if "`var'" == "q2" {
        	local c_note = "i"
        }
        else {
        	local c_note = "a"
        }
        ************** gov-affiliated GP ******************
        qui sum `var' 
        global mean_dp_all:dis %6.3f `r(mean)' 
        global sd_dp_all: dis %6.3f `r(sd)' 
				
		eststo col1_add_`c_note': qui reg `var' $leave1main gov_cri_1#gpabovemedian#lp_relation_gov, robust
				estadd local l_fe "No", replace
				qui tab gp_id if _est_col1_add_`c_note'
				estadd local u_id `r(r)', replace
				estadd local model_des "OLS"
				estadd local mean $mean_dp_all
				estadd local sd $sd_dp_all

}

**** latex output *******
esttab col1_add_i using "$appendixtable_dir/TableA23.tex", label booktabs eqlabels(none) replace ///
	star(* 0.1 ** 0.05 *** 0.01) t(%6.2f) b(%8.3f)  ///
        stats(N u_id r2 l_fe model_des mean sd,labels("Observations" "Unique GPs" "R-Squared"  "GP FEs" "Model" "DV Mean" "DV SD") fmt(a3 a3 %8.3f a3 a3 %6.3f %6.3f)) ///
	mtitle("Partner Rating") ///
	title("GP Preferences for LPs: Heterogeneity by Respondent Type") ///
	drop(_cons) 
/*==============================================================================
Table A24. GP Preferences for LPs: Heterogeneity by Government-Owned GPs, Controlling for Same Industry and Region
===============================================================================*/
use "$survey_dir/gp_reg_sameindustry_region.dta", clear

	drop if gp_id=="CAU"| gp_id=="FMZ" | gp_id=="OEJ"| gp_id=="QET"| gp_id=="QYN"| gp_id=="UTL"| gp_id=="UYM"| gp_id=="VUI"| gp_id=="XAJ"| gp_id=="XLJ"

	merge m:1 lp_profile_id using "$survey_dir/lp_profile_everyoption.dta", nogen keep(3)
	
	****** regrouping effort ****
	replace lp_ideology = 1 if stage_2 == 1
	replace lp_investment_stage = 0 if stage_2==1 | stage_5 == 1
	label var lp_investment_stage "Stage Focus"
	
	replace lp_aum = 0 if lp_aum<3
	replace lp_aum = 1 if lp_aum>=3 & !missing(lp_aum)
	label var lp_aum "Large Investor"
	
	**** relabeling ***
	label var lp_registered_cap_value "High Registered Capital"
	label var same_region "Same Investment Region"
	label var same_industry "Same Investment Industry"
	label var lp_relation_gov "Government Ties"
	label var lp_industry "Industry Information"
	label var lp_post_2010 "Young LP"
	label var lp_foreign_dummy "Headquarter In Foreign Country"
	label var lp_beijing_dummy "Headquarter In Beijing"
	label var lp_compliance "Corporate Governance"
	label var lp_ideology "Investment Philosophy"	
	
******** gp choose lp regression *****
global mainvar lp_relation_gov lp_aum lp_registered_cap_value lp_industry lp_post_2010 lp_foreign_dummy lp_beijing_dummy lp_compliance lp_ideology lp_investment_stage same_region same_industry
global control1 lp_invest_restriction lp_top lp_team_connection lp_team_experience
global fe_model i.gp_fe

global speci1 $mainvar 
global speci2 $mainvar $control1
global speci3 $speci1 $fe_model	
global speci4 $speci2 $fe_model


gen gov_cri_1 = (gp_total_gov_share>=0 & !missing(gp_total_gov_share)) // many other gov definitions could be used here

*Partner Rating *
foreach var in q2 {
	if "`var'"=="q1" {
        	local c_note = "m"
        }
        else if "`var'" == "q2" {
        	local c_note = "i"
        }
        else {
        	local c_note = "a"
        }
        ************** gov-affiliated GP ******************
        qui sum `var' if gov_cri_1 == 1
        global mean_dp_all:dis %6.3f `r(mean)' 
        global sd_dp_all: dis %6.3f `r(sd)' 
		
		qui sum `var' if gov_cri_1 == 0 
        global mean_dp_full:dis %6.3f `r(mean)' 
        global sd_dp_full: dis %6.3f `r(sd)' 

        forval i=1(2)3 {
                eststo col`i'_all_`c_note': qui reg `var' ${speci`i'} if gov_cri_1==1, robust
                        if `i'<=2 {
                                estadd local l_fe "No", replace
                        }
                        else {
                                estadd local l_fe "Yes", replace
                        }
                        qui tab gp_id if _est_col`i'_all_`c_note'
                        estadd local u_id `r(r)', replace
                        estadd local model_des "OLS"
                        estadd local mean $mean_dp_all
                        estadd local sd $sd_dp_all

				eststo col`i'_full_`c_note': qui reg `var' ${speci`i'} if gov_cri_1==0, robust
                        if `i'<=2 {
                                estadd local l_fe "No", replace
                        }
                        else {
                                estadd local l_fe "Yes", replace
                        }
                        qui tab gp_id if _est_col`i'_full_`c_note'
                        estadd local u_id `r(r)', replace
                        estadd local model_des "OLS"
                        estadd local mean $mean_dp_full
                        estadd local sd $sd_dp_full
        }
}


**** two tables for different samples *******
esttab col1_all_i col1_full_i col3_all_i col3_full_i using "$appendixtable_dir/TableA24_regression.tex", label booktabs eqlabels(none) replace ///
	star(* 0.1 ** 0.05 *** 0.01) t(%6.2f) b(%8.3f)  ///
        stats(N u_id r2 l_fe model_des mean sd,labels("Observations" "Unique GPs" "R-Squared"  "GP FEs" "Model" "DV Mean" "DV SD") fmt(a3 a3 %8.3f a3 a3 %6.3f %6.3f)) ///
	mtitle("Gov" "Non-Gov" "Gov" "Non-Gov") title("GP Preferences for LPs: Heterogeneity by Government-Owned GPs, Controlling for Same Industry and Region") ///
	drop(*gp_fe _cons) 

**** test coefficient ****
bysort gp_fe: center q1 q2 q3, prefix(cy_)
bysort gp_fe: center $speci1, prefix(cx_)
*** gov_affiliated GP vs non_gov_affiliated GP ***
*Cooperation Interest (Meeting Dummy) Partner Grading  Expected Interests  for different samples*
foreach var in q2 {
	if "`var'"=="q1" {
        	local c_note = "m"
        }
        else if "`var'" == "q2" {
        	local c_note = "i"
        }
        else {
        	local c_note = "a"
        }
	************** gov-affiliated GP ******************
        eststo col3_all_`c_note': qui reg `var' $speci1 if gov_cri_1==1
        eststo col6_all_`c_note': qui reg cy_`var' cx_* if gov_cri_1==1
       
        ****** non gov-affiliated GP *****
        eststo col3_all_n_`c_note': qui reg `var' $speci1 if gov_cri_1==0
        eststo col6_all_n_`c_note': qui reg cy_`var' cx_* if gov_cri_1==0

        ***** generate the estimator comparison for two groups for the same dep var ****
        
        ***** all sample ***
        eststo com1_all_`c_note': qui suest col3_all_`c_note' col3_all_n_`c_note', vce(robust)
        foreach var in $speci1 {
                qui test [col3_all_`c_note'_mean]`var'=[col3_all_n_`c_note'_mean]`var'
                estadd scalar `var' = r(p)
                
        }
        estadd local l_fe "No" 

        eststo com2_all_`c_note': qui suest col6_all_`c_note' col6_all_n_`c_note', vce(robust)
        foreach var in $speci1 {
                qui test [col6_all_`c_note'_mean]cx_`var'=[col6_all_n_`c_note'_mean]cx_`var'
                estadd scalar `var' = r(p)        
        }
        estadd local l_fe "Yes" 
        
        
}

esttab com1_all_i com2_all_i using "$appendixtable_dir/TableA24_SURtest.tex", label booktabs eqlabels(none) replace stats($speci1 l_fe, label("Government Ties" "Large Investor" "High Registered Capital" "Industry Information" "Young LP" "Headquarter In Foreign Country" "Headquarter In Beijing" "Corporate Governance" "Investment Philosophy" "Stage Focus" "Same Investment Region" "Same Investment Industry" "GP FEs") fmt(%8.3f %8.3f %8.3f %8.3f %8.3f %8.3f %8.3f %8.3f %8.3f %8.3f %8.3f a3)) ///
        mtitle("P-Value" "P-Value") title("Difference in Coefficients (p-value) Gov VS Non-Gov (Full Sample)") drop(*)

eststo clear

**** to form the final table, use a simple Python code to transform the latex files （text_gene.py）***
/*==============================================================================
Table A25. GP Preferences for LPs, Controlling for Same Industry and Region
===============================================================================*/
use "$survey_dir/gp_reg_sameindustry_region.dta", clear

	drop if gp_id=="CAU"| gp_id=="FMZ" | gp_id=="OEJ"| gp_id=="QET"| gp_id=="QYN"| gp_id=="UTL"| gp_id=="UYM"| gp_id=="VUI"| gp_id=="XAJ"| gp_id=="XLJ"

	merge m:1 lp_profile_id using "$survey_dir/lp_profile_everyoption", nogen keep(3)
	
	****** regrouping effort ****
	replace lp_ideology = 1 if stage_2 == 1
	replace lp_investment_stage = 0 if stage_2==1 | stage_5 == 1
	label var lp_investment_stage "Stage Focus"

	replace lp_aum = 0 if lp_aum<3
	replace lp_aum = 1 if lp_aum>=3 & !missing(lp_aum)
	label var lp_aum "Large Investor"
	
	**** relabeling ***
	label var lp_registered_cap_value "High Registered Capital"
	label var same_region "Same Investment Region"
	label var same_industry "Same Investment Industry"
	label var lp_relation_gov "Government Ties"
	label var lp_industry "Industry Information"
	label var lp_post_2010 "Young LP"
	label var lp_foreign_dummy "Headquarter In Foreign Country"
	label var lp_beijing_dummy "Headquarter In Beijing"
	label var lp_compliance "Corporate Governance"
	label var lp_ideology "Investment Philosophy"
	
******** gp choose lp regression (specifications) *****
global mainvar lp_relation_gov lp_aum lp_registered_cap_value lp_industry lp_post_2010 lp_foreign_dummy lp_beijing_dummy lp_compliance lp_ideology lp_investment_stage same_region same_industry
global control1 lp_invest_restriction lp_top lp_team_connection lp_team_experience
global fe_model i.gp_fe

global speci1 $mainvar 
global speci2 $mainvar $control1
global speci3 $speci1 $fe_model	
global speci4 $speci2 $fe_model


*Cooperation Interest (Meeting Dummy) / Partner Rating / Expected Interests*
foreach var in q2 {
	if "`var'"=="q1" {
        	local c_note = "m"
        }
        else if "`var'" == "q2" {
        	local c_note = "i"
        }
        else {
        	local c_note = "a"
        }
        ************** gov-affiliated GP ******************
        qui sum `var' 
        global mean_dp_all:dis %6.3f `r(mean)' 
        global sd_dp_all: dis %6.3f `r(sd)' 

        forval i=1(1)4 {
                eststo col`i'_all_`c_note': qui reg `var' ${speci`i'}, robust
                        if `i'<=2 {
                                estadd local l_fe "No", replace
                        }
                        else {
                                estadd local l_fe "Yes", replace
                        }
                        qui tab gp_id if _est_col`i'_all_`c_note'
                        estadd local u_id `r(r)', replace
                        estadd local model_des "OLS"
                        estadd local mean $mean_dp_all
                        estadd local sd $sd_dp_all
        }
}

**** output table *******
esttab col1_all_i col3_all_i using "$appendixtable_dir/TableA25.tex", label booktabs eqlabels(none) replace ///
	star(* 0.1 ** 0.05 *** 0.01) t(%6.2f) b(%8.3f)  ///
        stats(N u_id r2 l_fe model_des mean sd,labels("Observations" "Unique GPs" "R-Squared"  "GP FEs" "Model" "DV Mean" "DV SD") fmt(a3 a3 %8.3f a3 a3 %6.3f %6.3f)) ///
	mtitle("Partner" "Rating") title(" GP Preferences for LPs, Controlling for Same Industry and Region") ///
	drop(*gp_fe _cons) 

	
	
/*==============================================================================
Table A26. GP Preferences for LPs: Heterogeneity by Government-Owned GPs, Controlling for Having Government Investors
===============================================================================*/
use "$zero2ipo_dir/ActiveOwnershipLP_2015-19_SummaryStats.dta", clear
	keep lp_fullname govlp
	tempfile govlp
	save `govlp', replace
	
use "$zero2ipo_dir/ActiveOwnershipGP_2015-19_SummaryStats.dta", clear
	keep gp_fullname gp_respondent
	tempfile gpresp
	save `gpresp', replace

use "$zero2ipo_dir/GP-fund-LP_linkage.dta", clear
	ren LP_fullname lp_fullname
	ren GP_fullname gp_fullname
	merge m:1 lp_fullname using `govlp', nogen keep (3)
	keep if closing_year >= 2018
	collapse (sum) govlp, by (gp_fullname)
	gen govlplink = (govlp>0)
	drop govlp
	merge 1:1 gp_fullname using `gpresp', nogen
	keep if gp_respondent == 1 & !missing(gp_respondent)
	replace govlplink = (govlplink==1 & !missing(govlplink))
	tempfile govlplink
	save `govlplink', replace

use "$survey_dir/gp_survey_data_regress.dta", clear

	drop if gp_id=="CAU"| gp_id=="FMZ" | gp_id=="OEJ"| gp_id=="QET"| gp_id=="QYN"| gp_id=="UTL"| gp_id=="UYM"| gp_id=="VUI"| gp_id=="XAJ"| gp_id=="XLJ"
	
	merge m:1 gp_fullname using `govlplink', nogen 
	drop if missing(lp_profile_id)

	merge m:1 lp_profile_id using "$survey_dir/lp_profile_everyoption", nogen keep(3)
	
	****** regrouping effort 1 ****
	replace lp_ideology = 1 if stage_2 == 1
	replace lp_investment_stage = 0 if stage_2==1 | stage_5 == 1
	
	label var lp_investment_stage "Stage Focus"
	
	**** regrouping effort 2 ****
	label var lp_invest_restriction "GGF Extra Details"
	
	***** regrouping effort 3 *****
	replace lp_aum = 0 if lp_aum<3
	replace lp_aum = 1 if lp_aum>=3 & !missing(lp_aum)
	label var lp_aum "Large Investor"
	
	**** relabeling ***
	label var lp_registered_cap_value "High Registered Capital"
	label var govlplink "Had Gov-LP"
	
	
******** gp choose lp regression *****
global mainvar lp_relation_gov lp_aum lp_registered_cap_value lp_industry lp_post_2010 lp_foreign_dummy lp_beijing_dummy lp_compliance lp_ideology lp_investment_stage govlplink
global control1 lp_invest_restriction lp_top lp_team_connection lp_team_experience
global fe_model i.gp_fe

global speci1 $mainvar 
global speci2 $mainvar $control1
global speci3 $speci1 $fe_model	
global speci4 $speci2 $fe_model


gen gov_cri_1 = (gp_total_gov_share>=0 & !missing(gp_total_gov_share)) // many other gov definitions could be used here

*Partner Rating *
foreach var in q2 {
	if "`var'"=="q1" {
        	local c_note = "m"
        }
        else if "`var'" == "q2" {
        	local c_note = "i"
        }
        else {
        	local c_note = "a"
        }
        ************** gov-affiliated GP ******************
        qui sum `var' if gov_cri_1 == 1
        global mean_dp_all:dis %6.3f `r(mean)' 
        global sd_dp_all: dis %6.3f `r(sd)' 
		
		qui sum `var' if gov_cri_1 == 0 
        global mean_dp_full:dis %6.3f `r(mean)' 
        global sd_dp_full: dis %6.3f `r(sd)' 

        forval i=1(2)3 {
                eststo col`i'_all_`c_note': qui reg `var' ${speci`i'} if gov_cri_1==1, robust
                        if `i'<=2 {
                                estadd local l_fe "No", replace
                        }
                        else {
                                estadd local l_fe "Yes", replace
                        }
                        qui tab gp_id if _est_col`i'_all_`c_note'
                        estadd local u_id `r(r)', replace
                        estadd local model_des "OLS"
                        estadd local mean $mean_dp_all
                        estadd local sd $sd_dp_all

				eststo col`i'_full_`c_note': qui reg `var' ${speci`i'} if gov_cri_1==0, robust
                        if `i'<=2 {
                                estadd local l_fe "No", replace
                        }
                        else {
                                estadd local l_fe "Yes", replace
                        }
                        qui tab gp_id if _est_col`i'_full_`c_note'
                        estadd local u_id `r(r)', replace
                        estadd local model_des "OLS"
                        estadd local mean $mean_dp_full
                        estadd local sd $sd_dp_full
        }
}


**** two tables for different samples *******
esttab col1_all_i col1_full_i col3_all_i col3_full_i using "$appendixtable_dir/TableA26_regression.tex", label booktabs eqlabels(none) replace ///
	star(* 0.1 ** 0.05 *** 0.01) t(%6.2f) b(%8.3f)  ///
        stats(N u_id r2 l_fe model_des mean sd,labels("Observations" "Unique GPs" "R-Squared"  "GP FEs" "Model" "DV Mean" "DV SD") fmt(a3 a3 %8.3f a3 a3 %6.3f %6.3f)) ///
	mtitle("Gov" "Non-Gov" "Gov" "Non-Gov") title("GP Preferences for LPs: Heterogeneity by Government-Owned GPs, Controlling for Having Government Investors") ///
	drop(*gp_fe _cons) 

**** test coefficient ****
bysort gp_fe: center q1 q2 q3, prefix(cy_)
bysort gp_fe: center $speci1, prefix(cx_)
*** gov_affiliated GP vs non_gov_affiliated GP ***
*Cooperation Interest (Meeting Dummy) Partner Grading  Expected Interests  for different samples*
foreach var in q2 {
	if "`var'"=="q1" {
        	local c_note = "m"
        }
        else if "`var'" == "q2" {
        	local c_note = "i"
        }
        else {
        	local c_note = "a"
        }
	************** gov-affiliated GP ******************
        eststo col3_all_`c_note': qui reg `var' $speci1 if gov_cri_1==1
        eststo col6_all_`c_note': qui reg cy_`var' cx_* if gov_cri_1==1
       
        ****** non gov-affiliated GP *****
        eststo col3_all_n_`c_note': qui reg `var' $speci1 if gov_cri_1==0
        eststo col6_all_n_`c_note': qui reg cy_`var' cx_* if gov_cri_1==0

        ***** generate the estimator comparison for two groups for the same dep var ****
        
        ***** all sample ***
        eststo com1_all_`c_note': qui suest col3_all_`c_note' col3_all_n_`c_note', vce(robust)
        foreach var in $speci1 {
                /*qui*/ test [col3_all_`c_note'_mean]`var'=[col3_all_n_`c_note'_mean]`var'
                estadd scalar `var' = r(p)
                
        }
        estadd local l_fe "No" 

        eststo com2_all_`c_note': qui suest col6_all_`c_note' col6_all_n_`c_note', vce(robust)
        foreach var in $speci1 {
                /*qui*/test [col6_all_`c_note'_mean]cx_`var'=[col6_all_n_`c_note'_mean]cx_`var'
                estadd scalar `var' = r(p)        
        }
        estadd local l_fe "Yes" 
        
        
}



esttab com1_all_i com2_all_i using "$appendixtable_dir/TableA26_SURtest.tex", label booktabs eqlabels(none) replace stats($speci1 l_fe, label("Government Ties" "Large Investor" "High Registered Capital" "Industry Information" "Young LP" "Headquarter In Foreign Country" "Headquarter In Beijing" "Corporate Governance" "Investment Philosophy" "Stage Focus" "Had Gov-LP" "GP FEs") fmt(%8.3f %8.3f %8.3f %8.3f %8.3f %8.3f %8.3f %8.3f %8.3f %8.3f %8.3f a3)) ///
        mtitle("P-Value" "P-Value") title("Difference in Coefficients (p-value) Gov VS Non-Gov (Full Sample)") drop(*)

eststo clear

**** to form the final table, use a simple Python code to transform the latex files （text_gene.py）***



/*==============================================================================
Table A27. GP Preferences for LPs: Heterogeneity by Gov-LP-linked GPs
===============================================================================*/
use "$zero2ipo_dir/ActiveOwnershipLP_2015-19_SummaryStats.dta", clear
	keep lp_fullname govlp
	tempfile govlp
	save `govlp', replace
	
use "$zero2ipo_dir/ActiveOwnershipGP_2015-19_SummaryStats.dta", clear
	keep gp_fullname gp_respondent
	tempfile gpresp
	save `gpresp', replace

use "$zero2ipo_dir/GP-fund-LP_linkage.dta", clear
	ren LP_fullname lp_fullname
	ren GP_fullname gp_fullname
	merge m:1 lp_fullname using `govlp', nogen keep (3)
	keep if closing_year >= 2018
	collapse (sum) govlp, by (gp_fullname)
	gen govlplink = (govlp>0)
	drop govlp
	merge 1:1 gp_fullname using `gpresp', nogen
	keep if gp_respondent == 1 & !missing(gp_respondent)
	replace govlplink = (govlplink==1 & !missing(govlplink))
	tempfile govlplink
	save `govlplink', replace

use "$survey_dir/gp_survey_data_regress.dta", clear

	drop if gp_id=="CAU"| gp_id=="FMZ" | gp_id=="OEJ"| gp_id=="QET"| gp_id=="QYN"| gp_id=="UTL"| gp_id=="UYM"| gp_id=="VUI"| gp_id=="XAJ"| gp_id=="XLJ"
	
	merge m:1 gp_fullname using `govlplink', nogen 
	drop if missing(lp_profile_id)

	merge m:1 lp_profile_id using "$survey_dir/lp_profile_everyoption.dta", nogen keep(3)
	
	****** regrouping effort 1 ****
	replace lp_ideology = 1 if stage_2 == 1
	replace lp_investment_stage = 0 if stage_2==1 | stage_5 == 1
	
	label var lp_investment_stage "Stage Focus"
	
	**** regrouping effort 2 ****
	label var lp_invest_restriction "GGF Extra Details"
	
	***** regrouping effort 3 *****
	replace lp_aum = 0 if lp_aum<3
	replace lp_aum = 1 if lp_aum>=3 & !missing(lp_aum)
	label var lp_aum "Large Investor"
	
	**** relabeling ***
	label var lp_registered_cap_value "High Registered Capital"
	
	
******** gp choose lp regression *****
global mainvar lp_relation_gov lp_aum lp_registered_cap_value lp_industry lp_post_2010 lp_foreign_dummy lp_beijing_dummy lp_compliance lp_ideology lp_investment_stage 
global control1 lp_invest_restriction lp_top lp_team_connection lp_team_experience
global fe_model i.gp_fe

global speci1 $mainvar 
global speci2 $mainvar $control1
global speci3 $speci1 $fe_model	
global speci4 $speci2 $fe_model


gen gov_cri_1 = (gp_total_gov_share>=0 & !missing(gp_total_gov_share)) // many other gov definitions could be used here

*Partner Rating *
foreach var in q2 {
	if "`var'"=="q1" {
        	local c_note = "m"
        }
        else if "`var'" == "q2" {
        	local c_note = "i"
        }
        else {
        	local c_note = "a"
        }
        ************** gov-affiliated GP ******************
        qui sum `var' if govlplink == 1
        global mean_dp_all:dis %6.3f `r(mean)' 
        global sd_dp_all: dis %6.3f `r(sd)' 
		
		qui sum `var' if govlplink == 0 
        global mean_dp_full:dis %6.3f `r(mean)' 
        global sd_dp_full: dis %6.3f `r(sd)' 

        forval i=1(2)3 {
                eststo col`i'_all_`c_note': qui reg `var' ${speci`i'} if govlplink==1, robust
                        if `i'<=2 {
                                estadd local l_fe "No", replace
                        }
                        else {
                                estadd local l_fe "Yes", replace
                        }
                        qui tab gp_id if _est_col`i'_all_`c_note'
                        estadd local u_id `r(r)', replace
                        estadd local model_des "OLS"
                        estadd local mean $mean_dp_all
                        estadd local sd $sd_dp_all

				eststo col`i'_full_`c_note': qui reg `var' ${speci`i'} if govlplink==0, robust
                        if `i'<=2 {
                                estadd local l_fe "No", replace
                        }
                        else {
                                estadd local l_fe "Yes", replace
                        }
                        qui tab gp_id if _est_col`i'_full_`c_note'
                        estadd local u_id `r(r)', replace
                        estadd local model_des "OLS"
                        estadd local mean $mean_dp_full
                        estadd local sd $sd_dp_full
        }
}


**** two tables for different samples *******
esttab col1_all_i col1_full_i col3_all_i col3_full_i using "$appendixtable_dir/TableA27_regression.tex", label booktabs eqlabels(none) replace ///
	star(* 0.1 ** 0.05 *** 0.01) t(%6.2f) b(%8.3f)  ///
        stats(N u_id r2 l_fe model_des mean sd,labels("Observations" "Unique GPs" "R-Squared"  "GP FEs" "Model" "DV Mean" "DV SD") fmt(a3 a3 %8.3f a3 a3 %6.3f %6.3f)) ///
	mtitle("W/Gov Inv" "W/out Gov Inv" "W/Gov Inv" "W/out Gov Inv") title("GP Preferences for LPs: Heterogeneity by Gov-LP-linked GPs") ///
	drop(*gp_fe _cons) 

**** test coefficient ****
bysort gp_fe: center q1 q2 q3, prefix(cy_)
bysort gp_fe: center $speci1, prefix(cx_)
*** gov_affiliated GP vs non_gov_affiliated GP ***
*Cooperation Interest (Meeting Dummy) Partner Grading  Expected Interests  for different samples*
foreach var in q2 {
	if "`var'"=="q1" {
        	local c_note = "m"
        }
        else if "`var'" == "q2" {
        	local c_note = "i"
        }
        else {
        	local c_note = "a"
        }
	************** gov-affiliated GP ******************
        eststo col3_all_`c_note': qui reg `var' $speci1 if govlplink==1
        eststo col6_all_`c_note': qui reg cy_`var' cx_* if govlplink==1
       
        ****** non gov-affiliated GP *****
        eststo col3_all_n_`c_note': qui reg `var' $speci1 if govlplink==0
        eststo col6_all_n_`c_note': qui reg cy_`var' cx_* if govlplink==0

        ***** generate the estimator comparison for two groups for the same dep var ****
        
        ***** all sample ***
        eststo com1_all_`c_note': qui suest col3_all_`c_note' col3_all_n_`c_note', vce(robust)
        foreach var in $speci1 {
                qui test [col3_all_`c_note'_mean]`var'=[col3_all_n_`c_note'_mean]`var'
                estadd scalar `var' = r(p)
                
        }
        estadd local l_fe "No" 

        eststo com2_all_`c_note': qui suest col6_all_`c_note' col6_all_n_`c_note', vce(robust)
        foreach var in $speci1 {
                qui test [col6_all_`c_note'_mean]cx_`var'=[col6_all_n_`c_note'_mean]cx_`var'
                estadd scalar `var' = r(p)        
        }
        estadd local l_fe "Yes" 
        
        
}


esttab com1_all_i com2_all_i using "$appendixtable_dir/TableA27_SURtest.tex", label booktabs eqlabels(none) replace stats($speci1 l_fe, label("Government Ties" "Large Investor" "High Registered Capital" "Industry Information" "Young LP" "Headquarter In Foreign Country" "Headquarter In Beijing" "Corporate Governance" "Investment Philosophy" "Stage Focus" "GP FEs") fmt(%8.3f %8.3f %8.3f %8.3f %8.3f %8.3f %8.3f %8.3f %8.3f %8.3f %8.3f a3)) ///
       mtitle("P-Value" "P-Value") title("Difference in Coefficients (p-value) Gov VS Non-Gov (Full Sample)") drop(*)

eststo clear

**** to form the final table, use a simple Python code to transform the latex files （text_gene.py）***

/*==============================================================================
Table A28. GP Preferences for LPs: Heterogeneity by Government-Owned GPs, Controlling for Having Central Government Investors
===============================================================================*/

use "$zero2ipo_dir/ActiveLP_ownership_by_layer.dta", clear
	keep lp_fullname gov level
	gen central = (level=="Central")
	gen provincial = (level=="Provincial")
	gen local = (level=="Local")
	drop level
	rename gov govlp
	tempfile govlp
	save `govlp', replace
	
use "$zero2ipo_dir/ActiveOwnershipGP_2015-19_SummaryStats.dta", clear
	keep gp_fullname gp_respondent
	tempfile gpresp
	save `gpresp', replace

use "$zero2ipo_dir/GP-fund-LP_linkage.dta", clear
	ren LP_fullname lp_fullname
	ren GP_fullname gp_fullname
	merge m:1 lp_fullname using `govlp', nogen keep (3)
	keep if closing_year >= 2018
	collapse (sum) govlp central provincial local, by (gp_fullname)
	gen govlplink = (govlp>0)
	gen centrallink = (central >= provincial & central >= local & govlp > 0)
	gen provinciallink = (provincial >= central & provincial >= local & govlp > 0)
	gen locallink = (local >= provincial & local >= central & govlp > 0)
	drop govlp central provincial local
	merge 1:1 gp_fullname using `gpresp', nogen
	keep if gp_respondent == 1 & !missing(gp_respondent)
	replace govlplink = (govlplink==1 & !missing(govlplink))
	tempfile govlplink
	save `govlplink', replace

use "$survey_dir/gp_survey_data_regress.dta", clear

	drop if gp_id=="CAU"| gp_id=="FMZ" | gp_id=="OEJ"| gp_id=="QET"| gp_id=="QYN"| gp_id=="UTL"| gp_id=="UYM"| gp_id=="VUI"| gp_id=="XAJ"| gp_id=="XLJ"
	
	merge m:1 gp_fullname using `govlplink', nogen 
	drop if missing(lp_profile_id)

	merge m:1 lp_profile_id using "$survey_dir/lp_profile_everyoption.dta", nogen keep(3)
	
	****** regrouping effort 1 ****
	replace lp_ideology = 1 if stage_2 == 1
	replace lp_investment_stage = 0 if stage_2==1 | stage_5 == 1
	
	label var lp_investment_stage "Stage Focus"
	
	**** regrouping effort 2 ****
	label var lp_invest_restriction "GGF Extra Details"
	
	***** regrouping effort 3 *****
	replace lp_aum = 0 if lp_aum<3
	replace lp_aum = 1 if lp_aum>=3 & !missing(lp_aum)
	label var lp_aum "Large Investor"
	
	**** relabeling ***
	label var lp_registered_cap_value "High Registered Capital"
	label var govlplink "Had Gov-LP"
	label var centrallink "Had Central Gov-LP"
	label var provinciallink "Had Provincial Gov-LP"
	label var locallink "Had Local Gov-LP"
	
	
******** gp choose lp regression *****
global mainvar lp_relation_gov lp_aum lp_registered_cap_value lp_industry lp_post_2010 lp_foreign_dummy lp_beijing_dummy lp_compliance lp_ideology lp_investment_stage centrallink
global control1 lp_invest_restriction lp_top lp_team_connection lp_team_experience
global fe_model i.gp_fe

global speci1 $mainvar 
global speci2 $mainvar $control1
global speci3 $speci1 $fe_model	
global speci4 $speci2 $fe_model


gen gov_cri_1 = (gp_total_gov_share>=0 & !missing(gp_total_gov_share)) // many other gov definitions could be used here

*Partner Rating *
foreach var in q2 {
	if "`var'"=="q1" {
        	local c_note = "m"
        }
        else if "`var'" == "q2" {
        	local c_note = "i"
        }
        else {
        	local c_note = "a"
        }
        ************** gov-affiliated GP ******************
        qui sum `var' if gov_cri_1 == 1
        global mean_dp_all:dis %6.3f `r(mean)' 
        global sd_dp_all: dis %6.3f `r(sd)' 
		
		qui sum `var' if gov_cri_1 == 0 
        global mean_dp_full:dis %6.3f `r(mean)' 
        global sd_dp_full: dis %6.3f `r(sd)' 

        forval i=1(2)3 {
                eststo col`i'_all_`c_note': qui reg `var' ${speci`i'} if gov_cri_1==1, robust
                        if `i'<=2 {
                                estadd local l_fe "No", replace
                        }
                        else {
                                estadd local l_fe "Yes", replace
                        }
                        qui tab gp_id if _est_col`i'_all_`c_note'
                        estadd local u_id `r(r)', replace
                        estadd local model_des "OLS"
                        estadd local mean $mean_dp_all
                        estadd local sd $sd_dp_all

				eststo col`i'_full_`c_note': qui reg `var' ${speci`i'} if gov_cri_1==0, robust
                        if `i'<=2 {
                                estadd local l_fe "No", replace
                        }
                        else {
                                estadd local l_fe "Yes", replace
                        }
                        qui tab gp_id if _est_col`i'_full_`c_note'
                        estadd local u_id `r(r)', replace
                        estadd local model_des "OLS"
                        estadd local mean $mean_dp_full
                        estadd local sd $sd_dp_full
        }
}


**** two tables for different samples *******
esttab col1_all_i col1_full_i col3_all_i col3_full_i using "$appendixtable_dir/TableA28_regression.tex", label booktabs eqlabels(none) replace ///
	star(* 0.1 ** 0.05 *** 0.01) t(%6.2f) b(%8.3f)  ///
        stats(N u_id r2 l_fe model_des mean sd,labels("Observations" "Unique GPs" "R-Squared"  "GP FEs" "Model" "DV Mean" "DV SD") fmt(a3 a3 %8.3f a3 a3 %6.3f %6.3f)) ///
	mtitle("Gov" "Non-Gov" "Gov" "Non-Gov") title("GP Preferences for LPs: Heterogeneity by Government-Owned GPs, Controlling for Having Central Government Investors") ///
	drop(*gp_fe _cons) 

**** test coefficient ****
bysort gp_fe: center q1 q2 q3, prefix(cy_)
bysort gp_fe: center $speci1, prefix(cx_)
*** gov_affiliated GP vs non_gov_affiliated GP ***
*Cooperation Interest (Meeting Dummy) Partner Grading  Expected Interests  for different samples*
foreach var in q2 {
	if "`var'"=="q1" {
        	local c_note = "m"
        }
        else if "`var'" == "q2" {
        	local c_note = "i"
        }
        else {
        	local c_note = "a"
        }
	************** gov-affiliated GP ******************
        eststo col3_all_`c_note': qui reg `var' $speci1 if gov_cri_1==1
        eststo col6_all_`c_note': qui reg cy_`var' cx_* if gov_cri_1==1
       
        ****** non gov-affiliated GP *****
        eststo col3_all_n_`c_note': qui reg `var' $speci1 if gov_cri_1==0
        eststo col6_all_n_`c_note': qui reg cy_`var' cx_* if gov_cri_1==0

        ***** generate the estimator comparison for two groups for the same dep var ****
        
        ***** all sample ***
        eststo com1_all_`c_note': qui suest col3_all_`c_note' col3_all_n_`c_note', vce(robust)
        foreach var in $speci1 {
                /*qui*/ test [col3_all_`c_note'_mean]`var'=[col3_all_n_`c_note'_mean]`var'
                estadd scalar `var' = r(p)
                
        }
        estadd local l_fe "No" 

        eststo com2_all_`c_note': qui suest col6_all_`c_note' col6_all_n_`c_note', vce(robust)
        foreach var in $speci1 {
                /*qui*/test [col6_all_`c_note'_mean]cx_`var'=[col6_all_n_`c_note'_mean]cx_`var'
                estadd scalar `var' = r(p)        
        }
        estadd local l_fe "Yes" 
        
        
}



esttab com1_all_i com2_all_i using "$appendixtable_dir/TableA28_SURtest.tex", label booktabs eqlabels(none) replace stats($speci1 l_fe, label("Government Ties" "Large Investor" "High Registered Capital" "Industry Information" "Young LP" "Headquarter In Foreign Country" "Headquarter In Beijing" "Corporate Governance" "Investment Philosophy" "Stage Focus" "Had Central Gov-LP" "GP FEs") fmt(%8.3f %8.3f %8.3f %8.3f %8.3f %8.3f %8.3f %8.3f %8.3f %8.3f %8.3f a3)) ///
       mtitle("P-Value" "P-Value") title("Difference in Coefficients (p-value) Gov VS Non-Gov (Full Sample)") drop(*)

eststo clear

**** to form the final table, use a simple Python code to transform the latex files （text_gene.py）***


/*==============================================================================
Table A29. GP Preferences for LPs: Heterogeneity by Government-Owned GPs, Controlling for Having Provincial Government Investors
===============================================================================*/

use "$zero2ipo_dir/ActiveLP_ownership_by_layer.dta", clear
	keep lp_fullname gov level
	gen central = (level=="Central")
	gen provincial = (level=="Provincial")
	gen local = (level=="Local")
	drop level
	rename gov govlp
	tempfile govlp
	save `govlp', replace
	
use "$zero2ipo_dir/ActiveOwnershipGP_2015-19_SummaryStats.dta", clear
	keep gp_fullname gp_respondent
	tempfile gpresp
	save `gpresp', replace

use "$zero2ipo_dir/GP-fund-LP_linkage.dta", clear
	ren LP_fullname lp_fullname
	ren GP_fullname gp_fullname
	merge m:1 lp_fullname using `govlp', nogen keep (3)
	keep if closing_year >= 2018
	collapse (sum) govlp central provincial local, by (gp_fullname)
	gen govlplink = (govlp>0)
	gen centrallink = (central >= provincial & central >= local & govlp > 0)
	gen provinciallink = (provincial >= central & provincial >= local & govlp > 0)
	gen locallink = (local >= provincial & local >= central & govlp > 0)
	drop govlp central provincial local
	merge 1:1 gp_fullname using `gpresp', nogen
	keep if gp_respondent == 1 & !missing(gp_respondent)
	replace govlplink = (govlplink==1 & !missing(govlplink))
	tempfile govlplink
	save `govlplink', replace

use "$survey_dir/gp_survey_data_regress.dta", clear

	drop if gp_id=="CAU"| gp_id=="FMZ" | gp_id=="OEJ"| gp_id=="QET"| gp_id=="QYN"| gp_id=="UTL"| gp_id=="UYM"| gp_id=="VUI"| gp_id=="XAJ"| gp_id=="XLJ"
	
	merge m:1 gp_fullname using `govlplink', nogen 
	drop if missing(lp_profile_id)

	merge m:1 lp_profile_id using "$survey_dir/lp_profile_everyoption.dta", nogen keep(3)
	
	****** regrouping effort 1 ****
	replace lp_ideology = 1 if stage_2 == 1
	replace lp_investment_stage = 0 if stage_2==1 | stage_5 == 1
	
	label var lp_investment_stage "Stage Focus"
	
	**** regrouping effort 2 ****
	label var lp_invest_restriction "GGF Extra Details"
	
	***** regrouping effort 3 *****
	replace lp_aum = 0 if lp_aum<3
	replace lp_aum = 1 if lp_aum>=3 & !missing(lp_aum)
	label var lp_aum "Large Investor"
	
	**** relabeling ***
	label var lp_registered_cap_value "High Registered Capital"
	label var govlplink "Had Gov-LP"
	label var centrallink "Had Central Gov-LP"
	label var provinciallink "Had Provincial Gov-LP"
	label var locallink "Had Local Gov-LP"
	
	
******** gp choose lp regression *****
global mainvar lp_relation_gov lp_aum lp_registered_cap_value lp_industry lp_post_2010 lp_foreign_dummy lp_beijing_dummy lp_compliance lp_ideology lp_investment_stage provinciallink
global control1 lp_invest_restriction lp_top lp_team_connection lp_team_experience
global fe_model i.gp_fe

global speci1 $mainvar 
global speci2 $mainvar $control1
global speci3 $speci1 $fe_model	
global speci4 $speci2 $fe_model


gen gov_cri_1 = (gp_total_gov_share>=0 & !missing(gp_total_gov_share)) // many other gov definitions could be used here

*Partner Rating *
foreach var in q2 {
	if "`var'"=="q1" {
        	local c_note = "m"
        }
        else if "`var'" == "q2" {
        	local c_note = "i"
        }
        else {
        	local c_note = "a"
        }
        ************** gov-affiliated GP ******************
        qui sum `var' if gov_cri_1 == 1
        global mean_dp_all:dis %6.3f `r(mean)' 
        global sd_dp_all: dis %6.3f `r(sd)' 
		
		qui sum `var' if gov_cri_1 == 0 
        global mean_dp_full:dis %6.3f `r(mean)' 
        global sd_dp_full: dis %6.3f `r(sd)' 

        forval i=1(2)3 {
                eststo col`i'_all_`c_note': qui reg `var' ${speci`i'} if gov_cri_1==1, robust
                        if `i'<=2 {
                                estadd local l_fe "No", replace
                        }
                        else {
                                estadd local l_fe "Yes", replace
                        }
                        qui tab gp_id if _est_col`i'_all_`c_note'
                        estadd local u_id `r(r)', replace
                        estadd local model_des "OLS"
                        estadd local mean $mean_dp_all
                        estadd local sd $sd_dp_all

				eststo col`i'_full_`c_note': qui reg `var' ${speci`i'} if gov_cri_1==0, robust
                        if `i'<=2 {
                                estadd local l_fe "No", replace
                        }
                        else {
                                estadd local l_fe "Yes", replace
                        }
                        qui tab gp_id if _est_col`i'_full_`c_note'
                        estadd local u_id `r(r)', replace
                        estadd local model_des "OLS"
                        estadd local mean $mean_dp_full
                        estadd local sd $sd_dp_full
        }
}


**** two tables for different samples *******
esttab col1_all_i col1_full_i col3_all_i col3_full_i using "$appendixtable_dir/TableA29_regression.tex", label booktabs eqlabels(none) replace ///
	star(* 0.1 ** 0.05 *** 0.01) t(%6.2f) b(%8.3f)  ///
        stats(N u_id r2 l_fe model_des mean sd,labels("Observations" "Unique GPs" "R-Squared"  "GP FEs" "Model" "DV Mean" "DV SD") fmt(a3 a3 %8.3f a3 a3 %6.3f %6.3f)) ///
	mtitle("Gov" "Non-Gov" "Gov" "Non-Gov") title("GP Preferences for LPs: Heterogeneity by Government-Owned GPs, Controlling for Having Provincial Government Investors") ///
	drop(*gp_fe _cons) 

**** test coefficient ****
bysort gp_fe: center q1 q2 q3, prefix(cy_)
bysort gp_fe: center $speci1, prefix(cx_)
*** gov_affiliated GP vs non_gov_affiliated GP ***
*Cooperation Interest (Meeting Dummy) Partner Grading  Expected Interests  for different samples*
foreach var in q2 {
	if "`var'"=="q1" {
        	local c_note = "m"
        }
        else if "`var'" == "q2" {
        	local c_note = "i"
        }
        else {
        	local c_note = "a"
        }
	************** gov-affiliated GP ******************
        eststo col3_all_`c_note': qui reg `var' $speci1 if gov_cri_1==1
        eststo col6_all_`c_note': qui reg cy_`var' cx_* if gov_cri_1==1
       
        ****** non gov-affiliated GP *****
        eststo col3_all_n_`c_note': qui reg `var' $speci1 if gov_cri_1==0
        eststo col6_all_n_`c_note': qui reg cy_`var' cx_* if gov_cri_1==0

        ***** generate the estimator comparison for two groups for the same dep var ****
        
        ***** all sample ***
        eststo com1_all_`c_note': qui suest col3_all_`c_note' col3_all_n_`c_note', vce(robust)
        foreach var in $speci1 {
                /*qui*/ test [col3_all_`c_note'_mean]`var'=[col3_all_n_`c_note'_mean]`var'
                estadd scalar `var' = r(p)
                
        }
        estadd local l_fe "No" 

        eststo com2_all_`c_note': qui suest col6_all_`c_note' col6_all_n_`c_note', vce(robust)
        foreach var in $speci1 {
                /*qui*/test [col6_all_`c_note'_mean]cx_`var'=[col6_all_n_`c_note'_mean]cx_`var'
                estadd scalar `var' = r(p)        
        }
        estadd local l_fe "Yes" 
        
        
}



esttab com1_all_i com2_all_i using "$appendixtable_dir/TableA29_SURtest.tex", label booktabs eqlabels(none) replace stats($speci1 l_fe, label("Government Ties" "Large Investor" "High Registered Capital" "Industry Information" "Young LP" "Headquarter In Foreign Country" "Headquarter In Beijing" "Corporate Governance" "Investment Philosophy" "Stage Focus" "Had Provincial Gov-LP" "GP FEs") fmt(%8.3f %8.3f %8.3f %8.3f %8.3f %8.3f %8.3f %8.3f %8.3f %8.3f %8.3f a3)) ///
        mtitle("P-Value" "P-Value") title("Difference in Coefficients (p-value) Gov VS Non-Gov (Full Sample)") drop(*)

eststo clear

**** to form the final table, use a simple Python code to transform the latex files （text_gene.py）***


/*==============================================================================
Table A30. GP Preferences for LPs: Heterogeneity by Government-Owned GPs, Controlling for Having Local Government Investors
===============================================================================*/
use "$zero2ipo_dir/ActiveLP_ownership_by_layer.dta", clear
	keep lp_fullname gov level
	gen central = (level=="Central")
	gen provincial = (level=="Provincial")
	gen local = (level=="Local")
	drop level
	rename gov govlp
	tempfile govlp
	save `govlp', replace
	
use "$zero2ipo_dir/ActiveOwnershipGP_2015-19_SummaryStats.dta", clear
	keep gp_fullname gp_respondent
	tempfile gpresp
	save `gpresp', replace

use "$zero2ipo_dir/GP-fund-LP_linkage.dta", clear
	ren LP_fullname lp_fullname
	ren GP_fullname gp_fullname
	merge m:1 lp_fullname using `govlp', nogen keep (3)
	keep if closing_year >= 2018
	collapse (sum) govlp central provincial local, by (gp_fullname)
	gen govlplink = (govlp>0)
	gen centrallink = (central >= provincial & central >= local & govlp > 0)
	gen provinciallink = (provincial >= central & provincial >= local & govlp > 0)
	gen locallink = (local >= provincial & local >= central & govlp > 0)
	drop govlp central provincial local
	merge 1:1 gp_fullname using `gpresp', nogen
	keep if gp_respondent == 1 & !missing(gp_respondent)
	replace govlplink = (govlplink==1 & !missing(govlplink))
	tempfile govlplink
	save `govlplink', replace

use "$survey_dir/gp_survey_data_regress.dta", clear

	drop if gp_id=="CAU"| gp_id=="FMZ" | gp_id=="OEJ"| gp_id=="QET"| gp_id=="QYN"| gp_id=="UTL"| gp_id=="UYM"| gp_id=="VUI"| gp_id=="XAJ"| gp_id=="XLJ"
	
	merge m:1 gp_fullname using `govlplink', nogen 
	drop if missing(lp_profile_id)

	merge m:1 lp_profile_id using "$survey_dir/lp_profile_everyoption.dta", nogen keep(3)
	
	****** regrouping effort 1 ****
	replace lp_ideology = 1 if stage_2 == 1
	replace lp_investment_stage = 0 if stage_2==1 | stage_5 == 1
	
	label var lp_investment_stage "Stage Focus"
	
	**** regrouping effort 2 ****
	label var lp_invest_restriction "GGF Extra Details"
	
	***** regrouping effort 3 *****
	replace lp_aum = 0 if lp_aum<3
	replace lp_aum = 1 if lp_aum>=3 & !missing(lp_aum)
	label var lp_aum "Large Investor"
	
	**** relabeling ***
	label var lp_registered_cap_value "High Registered Capital"
	label var govlplink "Had Gov-LP"
	label var centrallink "Had Central Gov-LP"
	label var provinciallink "Had Provincial Gov-LP"
	label var locallink "Had Local Gov-LP"
	
	
******** gp choose lp regression *****
global mainvar lp_relation_gov lp_aum lp_registered_cap_value lp_industry lp_post_2010 lp_foreign_dummy lp_beijing_dummy lp_compliance lp_ideology lp_investment_stage locallink
global control1 lp_invest_restriction lp_top lp_team_connection lp_team_experience
global fe_model i.gp_fe

global speci1 $mainvar 
global speci2 $mainvar $control1
global speci3 $speci1 $fe_model	
global speci4 $speci2 $fe_model


gen gov_cri_1 = (gp_total_gov_share>=0 & !missing(gp_total_gov_share)) // many other gov definitions could be used here

*Partner Rating *
foreach var in q2 {
	if "`var'"=="q1" {
        	local c_note = "m"
        }
        else if "`var'" == "q2" {
        	local c_note = "i"
        }
        else {
        	local c_note = "a"
        }
        ************** gov-affiliated GP ******************
        qui sum `var' if gov_cri_1 == 1
        global mean_dp_all:dis %6.3f `r(mean)' 
        global sd_dp_all: dis %6.3f `r(sd)' 
		
		qui sum `var' if gov_cri_1 == 0 
        global mean_dp_full:dis %6.3f `r(mean)' 
        global sd_dp_full: dis %6.3f `r(sd)' 

        forval i=1(2)3 {
                eststo col`i'_all_`c_note': qui reg `var' ${speci`i'} if gov_cri_1==1, robust
                        if `i'<=2 {
                                estadd local l_fe "No", replace
                        }
                        else {
                                estadd local l_fe "Yes", replace
                        }
                        qui tab gp_id if _est_col`i'_all_`c_note'
                        estadd local u_id `r(r)', replace
                        estadd local model_des "OLS"
                        estadd local mean $mean_dp_all
                        estadd local sd $sd_dp_all

				eststo col`i'_full_`c_note': qui reg `var' ${speci`i'} if gov_cri_1==0, robust
                        if `i'<=2 {
                                estadd local l_fe "No", replace
                        }
                        else {
                                estadd local l_fe "Yes", replace
                        }
                        qui tab gp_id if _est_col`i'_full_`c_note'
                        estadd local u_id `r(r)', replace
                        estadd local model_des "OLS"
                        estadd local mean $mean_dp_full
                        estadd local sd $sd_dp_full
        }
}


**** two tables for different samples *******
esttab col1_all_i col1_full_i col3_all_i col3_full_i using "$appendixtable_dir/TableA30_regression.tex", label booktabs eqlabels(none) replace ///
	star(* 0.1 ** 0.05 *** 0.01) t(%6.2f) b(%8.3f)  ///
        stats(N u_id r2 l_fe model_des mean sd,labels("Observations" "Unique GPs" "R-Squared"  "GP FEs" "Model" "DV Mean" "DV SD") fmt(a3 a3 %8.3f a3 a3 %6.3f %6.3f)) ///
	mtitle("Gov" "Non-Gov" "Gov" "Non-Gov") title("GP Preferences for LPs: Heterogeneity by Government-Owned GPs, Controlling for Having Local Government Investors") ///
	drop(*gp_fe _cons) 

**** test coefficient ****
bysort gp_fe: center q1 q2 q3, prefix(cy_)
bysort gp_fe: center $speci1, prefix(cx_)
*** gov_affiliated GP vs non_gov_affiliated GP ***
*Cooperation Interest (Meeting Dummy) Partner Grading  Expected Interests  for different samples*
foreach var in q2 {
	if "`var'"=="q1" {
        	local c_note = "m"
        }
        else if "`var'" == "q2" {
        	local c_note = "i"
        }
        else {
        	local c_note = "a"
        }
	************** gov-affiliated GP ******************
        eststo col3_all_`c_note': qui reg `var' $speci1 if gov_cri_1==1
        eststo col6_all_`c_note': qui reg cy_`var' cx_* if gov_cri_1==1
       
        ****** non gov-affiliated GP *****
        eststo col3_all_n_`c_note': qui reg `var' $speci1 if gov_cri_1==0
        eststo col6_all_n_`c_note': qui reg cy_`var' cx_* if gov_cri_1==0

        ***** generate the estimator comparison for two groups for the same dep var ****
        
        ***** all sample ***
        eststo com1_all_`c_note': qui suest col3_all_`c_note' col3_all_n_`c_note', vce(robust)
        foreach var in $speci1 {
                /*qui*/ test [col3_all_`c_note'_mean]`var'=[col3_all_n_`c_note'_mean]`var'
                estadd scalar `var' = r(p)
                
        }
        estadd local l_fe "No" 

        eststo com2_all_`c_note': qui suest col6_all_`c_note' col6_all_n_`c_note', vce(robust)
        foreach var in $speci1 {
                /*qui*/test [col6_all_`c_note'_mean]cx_`var'=[col6_all_n_`c_note'_mean]cx_`var'
                estadd scalar `var' = r(p)        
        }
        estadd local l_fe "Yes" 
        
        
}



esttab com1_all_i com2_all_i using "$appendixtable_dir/TableA30_SURtest.tex", label booktabs eqlabels(none) replace stats($speci1 l_fe, label("Government Ties" "Large Investor" "High Registered Capital" "Industry Information" "Young LP" "Headquarter In Foreign Country" "Headquarter In Beijing" "Corporate Governance" "Investment Philosophy" "Stage Focus" "Had Local Gov-LP" "GP FEs") fmt(%8.3f %8.3f %8.3f %8.3f %8.3f %8.3f %8.3f %8.3f %8.3f %8.3f %8.3f a3)) ///
        mtitle("P-Value" "P-Value") title("Difference in Coefficients (p-value) Gov VS Non-Gov (Full Sample)") drop(*)

eststo clear

**** to form the final table, use a simple Python code to transform the latex files （text_gene.py）***
/*==============================================================================
Table A31. GP Preferences for LPs: Heterogeneity by Central Gov-LP-linked GPs
===============================================================================*/

use "$zero2ipo_dir/ActiveLP_ownership_by_layer.dta", clear
	keep lp_fullname gov level
	gen central = (level=="Central")
	gen provincial = (level=="Provincial")
	gen local = (level=="Local")
	drop level
	rename gov govlp
	tempfile govlp
	save `govlp', replace
	

	
use "$zero2ipo_dir/ActiveOwnershipGP_2015-19_SummaryStats.dta", clear
	keep gp_fullname gp_respondent
	tempfile gpresp
	save `gpresp', replace

use "$zero2ipo_dir/GP-fund-LP_linkage.dta", clear
	ren LP_fullname lp_fullname
	ren GP_fullname gp_fullname
	merge m:1 lp_fullname using `govlp', nogen keep (3)
	keep if closing_year >= 2018
	collapse (sum) govlp central provincial local, by (gp_fullname)
	gen govlplink = (govlp>0)
	gen centrallink = (central >= provincial & central >= local & govlp > 0)
	gen provinciallink = (provincial >= central & provincial >= local & govlp > 0)
	gen locallink = (local >= provincial & local >= central & govlp > 0)
	drop govlp central provincial local
	merge 1:1 gp_fullname using `gpresp', nogen
	keep if gp_respondent == 1 & !missing(gp_respondent)
	replace govlplink = (govlplink==1 & !missing(govlplink))
	tempfile govlplink
	save `govlplink', replace

use "$survey_dir/gp_survey_data_regress.dta", clear

	drop if gp_id=="CAU"| gp_id=="FMZ" | gp_id=="OEJ"| gp_id=="QET"| gp_id=="QYN"| gp_id=="UTL"| gp_id=="UYM"| gp_id=="VUI"| gp_id=="XAJ"| gp_id=="XLJ"
	
	merge m:1 gp_fullname using `govlplink', nogen 
	drop if missing(lp_profile_id)

	merge m:1 lp_profile_id using "$survey_dir/lp_profile_everyoption.dta", nogen keep(3)
	
	****** regrouping effort 1 ****
	replace lp_ideology = 1 if stage_2 == 1
	replace lp_investment_stage = 0 if stage_2==1 | stage_5 == 1
	
	label var lp_investment_stage "Stage Focus"
	
	**** regrouping effort 2 ****
	label var lp_invest_restriction "GGF Extra Details"
	
	***** regrouping effort 3 *****
	replace lp_aum = 0 if lp_aum<3
	replace lp_aum = 1 if lp_aum>=3 & !missing(lp_aum)
	label var lp_aum "Large Investor"
	
	**** relabeling ***
	label var lp_registered_cap_value "High Registered Capital"
	label var govlplink "Had Gov-LP"
	label var centrallink "Had Central Gov-LP"
	label var provinciallink "Had Provincial Gov-LP"
	label var locallink "Had Local Gov-LP"
	
	
******** gp choose lp regression *****
global mainvar lp_relation_gov lp_aum lp_registered_cap_value lp_industry lp_post_2010 lp_foreign_dummy lp_beijing_dummy lp_compliance lp_ideology lp_investment_stage 
global control1 lp_invest_restriction lp_top lp_team_connection lp_team_experience
global fe_model i.gp_fe

global speci1 $mainvar 
global speci2 $mainvar $control1
global speci3 $speci1 $fe_model	
global speci4 $speci2 $fe_model


gen gov_cri_1 = (gp_total_gov_share>=0 & !missing(gp_total_gov_share)) // many other gov definitions could be used here

*Partner Rating *
foreach var in q2 {
	if "`var'"=="q1" {
        	local c_note = "m"
        }
        else if "`var'" == "q2" {
        	local c_note = "i"
        }
        else {
        	local c_note = "a"
        }
        ************** gov-affiliated GP ******************
        qui sum `var' if centrallink == 1
        global mean_dp_all:dis %6.3f `r(mean)' 
        global sd_dp_all: dis %6.3f `r(sd)' 
		
		qui sum `var' if centrallink == 0 
        global mean_dp_full:dis %6.3f `r(mean)' 
        global sd_dp_full: dis %6.3f `r(sd)' 

        forval i=1(2)3 {
                eststo col`i'_all_`c_note': qui reg `var' ${speci`i'} if centrallink==1, robust
                        if `i'<=2 {
                                estadd local l_fe "No", replace
                        }
                        else {
                                estadd local l_fe "Yes", replace
                        }
                        qui tab gp_id if _est_col`i'_all_`c_note'
                        estadd local u_id `r(r)', replace
                        estadd local model_des "OLS"
                        estadd local mean $mean_dp_all
                        estadd local sd $sd_dp_all

				eststo col`i'_full_`c_note': qui reg `var' ${speci`i'} if centrallink==0, robust
                        if `i'<=2 {
                                estadd local l_fe "No", replace
                        }
                        else {
                                estadd local l_fe "Yes", replace
                        }
                        qui tab gp_id if _est_col`i'_full_`c_note'
                        estadd local u_id `r(r)', replace
                        estadd local model_des "OLS"
                        estadd local mean $mean_dp_full
                        estadd local sd $sd_dp_full
        }
}


**** two tables for different samples *******
esttab col1_all_i col1_full_i col3_all_i col3_full_i using "$appendixtable_dir/TableA31_regression.tex", label booktabs eqlabels(none) replace ///
	star(* 0.1 ** 0.05 *** 0.01) t(%6.2f) b(%8.3f)  ///
        stats(N u_id r2 l_fe model_des mean sd,labels("Observations" "Unique GPs" "R-Squared"  "GP FEs" "Model" "DV Mean" "DV SD") fmt(a3 a3 %8.3f a3 a3 %6.3f %6.3f)) ///
	mtitle("W/C_Gov" "W/out C_Gov" "W/C_Gov" "W/out C_Gov") title("GP Preferences for LPs: Heterogeneity by Central Gov-LP-linked GPs") ///
	drop(*gp_fe _cons) 

**** test coefficient ****
bysort gp_fe: center q1 q2 q3, prefix(cy_)
bysort gp_fe: center $speci1, prefix(cx_)
*** gov_affiliated GP vs non_gov_affiliated GP ***
*Cooperation Interest (Meeting Dummy) Partner Grading  Expected Interests  for different samples*
foreach var in q2 {
	if "`var'"=="q1" {
        	local c_note = "m"
        }
        else if "`var'" == "q2" {
        	local c_note = "i"
        }
        else {
        	local c_note = "a"
        }
	************** gov-affiliated GP ******************
        eststo col3_all_`c_note': qui reg `var' $speci1 if centrallink==1
        eststo col6_all_`c_note': qui reg cy_`var' cx_* if centrallink==1
       
        ****** non gov-affiliated GP *****
        eststo col3_all_n_`c_note': qui reg `var' $speci1 if centrallink==0
        eststo col6_all_n_`c_note': qui reg cy_`var' cx_* if centrallink==0

        ***** generate the estimator comparison for two groups for the same dep var ****
        
        ***** all sample ***
        eststo com1_all_`c_note': qui suest col3_all_`c_note' col3_all_n_`c_note', vce(robust)
        foreach var in $speci1 {
                qui test [col3_all_`c_note'_mean]`var'=[col3_all_n_`c_note'_mean]`var'
                estadd scalar `var' = r(p)
                
        }
        estadd local l_fe "No" 

        eststo com2_all_`c_note': qui suest col6_all_`c_note' col6_all_n_`c_note', vce(robust)
        foreach var in $speci1 {
                qui test [col6_all_`c_note'_mean]cx_`var'=[col6_all_n_`c_note'_mean]cx_`var'
                estadd scalar `var' = r(p)        
        }
        estadd local l_fe "Yes" 
        
        
}


esttab com1_all_i com2_all_i using "$appendixtable_dir/TableA31_SURtest.tex", label booktabs eqlabels(none) replace stats($speci1 l_fe, label("Government Ties" "Large Investor" "High Registered Capital" "Industry Information" "Young LP" "Headquarter In Foreign Country" "Headquarter In Beijing" "Corporate Governance" "Investment Philosophy" "Stage Focus" "GP FEs") fmt(%8.3f %8.3f %8.3f %8.3f %8.3f %8.3f %8.3f %8.3f %8.3f %8.3f %8.3f a3)) ///
        mtitle("P-Value" "P-Value") title("Difference in Coefficients (p-value) Gov VS Non-Gov (Full Sample)") drop(*)

eststo clear

**** to form the final table, use a simple Python code to transform the latex files （text_gene.py）***

/*==============================================================================
Table A32. GP Preferences for LPs: Heterogeneity by Provincial Gov-LP-linked GPs
===============================================================================*/

use "$zero2ipo_dir/ActiveLP_ownership_by_layer.dta", clear
	keep lp_fullname gov level
	gen central = (level=="Central")
	gen provincial = (level=="Provincial")
	gen local = (level=="Local")
	drop level
	rename gov govlp
	tempfile govlp
	save `govlp', replace
	

	
use "$zero2ipo_dir/ActiveOwnershipGP_2015-19_SummaryStats.dta", clear
	keep gp_fullname gp_respondent
	tempfile gpresp
	save `gpresp', replace

use "$zero2ipo_dir/GP-fund-LP_linkage.dta", clear
	ren LP_fullname lp_fullname
	ren GP_fullname gp_fullname
	merge m:1 lp_fullname using `govlp', nogen keep (3)
	keep if closing_year >= 2018
	collapse (sum) govlp central provincial local, by (gp_fullname)
	gen govlplink = (govlp>0)
	gen centrallink = (central >= provincial & central >= local & govlp > 0)
	gen provinciallink = (provincial >= central & provincial >= local & govlp > 0)
	gen locallink = (local >= provincial & local >= central & govlp > 0)
	drop govlp central provincial local
	merge 1:1 gp_fullname using `gpresp', nogen
	keep if gp_respondent == 1 & !missing(gp_respondent)
	replace govlplink = (govlplink==1 & !missing(govlplink))
	tempfile govlplink
	save `govlplink', replace

use "$survey_dir/gp_survey_data_regress.dta", clear

	drop if gp_id=="CAU"| gp_id=="FMZ" | gp_id=="OEJ"| gp_id=="QET"| gp_id=="QYN"| gp_id=="UTL"| gp_id=="UYM"| gp_id=="VUI"| gp_id=="XAJ"| gp_id=="XLJ"
	
	merge m:1 gp_fullname using `govlplink', nogen 
	drop if missing(lp_profile_id)

	merge m:1 lp_profile_id using "$survey_dir/lp_profile_everyoption.dta", nogen keep(3)
	
	****** regrouping effort 1 ****
	replace lp_ideology = 1 if stage_2 == 1
	replace lp_investment_stage = 0 if stage_2==1 | stage_5 == 1
	
	label var lp_investment_stage "Stage Focus"
	
	**** regrouping effort 2 ****
	label var lp_invest_restriction "GGF Extra Details"
	
	***** regrouping effort 3 *****
	replace lp_aum = 0 if lp_aum<3
	replace lp_aum = 1 if lp_aum>=3 & !missing(lp_aum)
	label var lp_aum "Large Investor"
	
	**** relabeling ***
	label var lp_registered_cap_value "High Registered Capital"
	label var govlplink "Had Gov-LP"
	label var centrallink "Had Central Gov-LP"
	label var provinciallink "Had Provincial Gov-LP"
	label var locallink "Had Local Gov-LP"
	
	
******** gp choose lp regression *****
global mainvar lp_relation_gov lp_aum lp_registered_cap_value lp_industry lp_post_2010 lp_foreign_dummy lp_beijing_dummy lp_compliance lp_ideology lp_investment_stage 
global control1 lp_invest_restriction lp_top lp_team_connection lp_team_experience
global fe_model i.gp_fe

global speci1 $mainvar 
global speci2 $mainvar $control1
global speci3 $speci1 $fe_model	
global speci4 $speci2 $fe_model


gen gov_cri_1 = (gp_total_gov_share>=0 & !missing(gp_total_gov_share)) // many other gov definitions could be used here

*Partner Rating *
foreach var in q2 {
	if "`var'"=="q1" {
        	local c_note = "m"
        }
        else if "`var'" == "q2" {
        	local c_note = "i"
        }
        else {
        	local c_note = "a"
        }
        ************** gov-affiliated GP ******************
        qui sum `var' if provinciallink == 1
        global mean_dp_all:dis %6.3f `r(mean)' 
        global sd_dp_all: dis %6.3f `r(sd)' 
		
		qui sum `var' if provinciallink == 0 
        global mean_dp_full:dis %6.3f `r(mean)' 
        global sd_dp_full: dis %6.3f `r(sd)' 

        forval i=1(2)3 {
                eststo col`i'_all_`c_note': qui reg `var' ${speci`i'} if provinciallink==1, robust
                        if `i'<=2 {
                                estadd local l_fe "No", replace
                        }
                        else {
                                estadd local l_fe "Yes", replace
                        }
                        qui tab gp_id if _est_col`i'_all_`c_note'
                        estadd local u_id `r(r)', replace
                        estadd local model_des "OLS"
                        estadd local mean $mean_dp_all
                        estadd local sd $sd_dp_all

				eststo col`i'_full_`c_note': qui reg `var' ${speci`i'} if provinciallink==0, robust
                        if `i'<=2 {
                                estadd local l_fe "No", replace
                        }
                        else {
                                estadd local l_fe "Yes", replace
                        }
                        qui tab gp_id if _est_col`i'_full_`c_note'
                        estadd local u_id `r(r)', replace
                        estadd local model_des "OLS"
                        estadd local mean $mean_dp_full
                        estadd local sd $sd_dp_full
        }
}


**** two tables for different samples *******
esttab col1_all_i col1_full_i col3_all_i col3_full_i using "$appendixtable_dir/TableA32_regression.tex", label booktabs eqlabels(none) replace ///
	star(* 0.1 ** 0.05 *** 0.01) t(%6.2f) b(%8.3f)  ///
        stats(N u_id r2 l_fe model_des mean sd,labels("Observations" "Unique GPs" "R-Squared"  "GP FEs" "Model" "DV Mean" "DV SD") fmt(a3 a3 %8.3f a3 a3 %6.3f %6.3f)) ///
	mtitle("W/P_Gov" "W/out P_Gov" "W/P_Gov" "W/out P_Gov") title("GP Preferences for LPs: Heterogeneity by Provincial Gov-LP-linked GPs") ///
	drop(*gp_fe _cons) 

**** test coefficient ****
bysort gp_fe: center q1 q2 q3, prefix(cy_)
bysort gp_fe: center $speci1, prefix(cx_)
*** gov_affiliated GP vs non_gov_affiliated GP ***
*Cooperation Interest (Meeting Dummy) Partner Grading  Expected Interests  for different samples*
foreach var in q2 {
	if "`var'"=="q1" {
        	local c_note = "m"
        }
        else if "`var'" == "q2" {
        	local c_note = "i"
        }
        else {
        	local c_note = "a"
        }
	************** gov-affiliated GP ******************
        eststo col3_all_`c_note': qui reg `var' $speci1 if provinciallink==1
        eststo col6_all_`c_note': qui reg cy_`var' cx_* if provinciallink==1
       
        ****** non gov-affiliated GP *****
        eststo col3_all_n_`c_note': qui reg `var' $speci1 if provinciallink==0
        eststo col6_all_n_`c_note': qui reg cy_`var' cx_* if provinciallink==0

        ***** generate the estimator comparison for two groups for the same dep var ****
        
        ***** all sample ***
        eststo com1_all_`c_note': qui suest col3_all_`c_note' col3_all_n_`c_note', vce(robust)
        foreach var in $speci1 {
                qui test [col3_all_`c_note'_mean]`var'=[col3_all_n_`c_note'_mean]`var'
                estadd scalar `var' = r(p)
                
        }
        estadd local l_fe "No" 

        eststo com2_all_`c_note': qui suest col6_all_`c_note' col6_all_n_`c_note', vce(robust)
        foreach var in $speci1 {
                qui test [col6_all_`c_note'_mean]cx_`var'=[col6_all_n_`c_note'_mean]cx_`var'
                estadd scalar `var' = r(p)        
        }
        estadd local l_fe "Yes" 
        
        
}


esttab com1_all_i com2_all_i using "$appendixtable_dir/TableA32_SURtest.tex", label booktabs eqlabels(none) replace stats($speci1 l_fe, label("Government Ties" "Large Investor" "High Registered Capital" "Industry Information" "Young LP" "Headquarter In Foreign Country" "Headquarter In Beijing" "Corporate Governance" "Investment Philosophy" "Stage Focus" "GP FEs") fmt(%8.3f %8.3f %8.3f %8.3f %8.3f %8.3f %8.3f %8.3f %8.3f %8.3f %8.3f a3)) ///
        mtitle("P-Value" "P-Value") title("Difference in Coefficients (p-value) Gov VS Non-Gov (Full Sample)") drop(*)

eststo clear

**** to form the final table, use a simple Python code to transform the latex files （text_gene.py）***
/*==============================================================================
Table A33. GP Preferences for LPs: Heterogeneity by Local Gov-LP-linked GPs
===============================================================================*/

use "$zero2ipo_dir/ActiveLP_ownership_by_layer.dta", clear
	keep lp_fullname gov level
	gen central = (level=="Central")
	gen provincial = (level=="Provincial")
	gen local = (level=="Local")
	drop level
	rename gov govlp
	tempfile govlp
	save `govlp', replace
	

	
use "$zero2ipo_dir/ActiveOwnershipGP_2015-19_SummaryStats.dta", clear
	keep gp_fullname gp_respondent
	tempfile gpresp
	save `gpresp', replace

use "$zero2ipo_dir/GP-fund-LP_linkage.dta", clear
	ren LP_fullname lp_fullname
	ren GP_fullname gp_fullname
	merge m:1 lp_fullname using `govlp', nogen keep (3)
	keep if closing_year >= 2018
	collapse (sum) govlp central provincial local, by (gp_fullname)
	gen govlplink = (govlp>0)
	gen centrallink = (central >= provincial & central >= local & govlp > 0)
	gen provinciallink = (provincial >= central & provincial >= local & govlp > 0)
	gen locallink = (local >= provincial & local >= central & govlp > 0)
	drop govlp central provincial local
	merge 1:1 gp_fullname using `gpresp', nogen
	keep if gp_respondent == 1 & !missing(gp_respondent)
	replace govlplink = (govlplink==1 & !missing(govlplink))
	tempfile govlplink
	save `govlplink', replace

use "$survey_dir/gp_survey_data_regress.dta", clear

	drop if gp_id=="CAU"| gp_id=="FMZ" | gp_id=="OEJ"| gp_id=="QET"| gp_id=="QYN"| gp_id=="UTL"| gp_id=="UYM"| gp_id=="VUI"| gp_id=="XAJ"| gp_id=="XLJ"
	
	merge m:1 gp_fullname using `govlplink', nogen 
	drop if missing(lp_profile_id)

	merge m:1 lp_profile_id using "$survey_dir/lp_profile_everyoption.dta", nogen keep(3)
	
	****** regrouping effort 1 ****
	replace lp_ideology = 1 if stage_2 == 1
	replace lp_investment_stage = 0 if stage_2==1 | stage_5 == 1
	
	label var lp_investment_stage "Stage Focus"
	
	**** regrouping effort 2 ****
	label var lp_invest_restriction "GGF Extra Details"
	
	***** regrouping effort 3 *****
	replace lp_aum = 0 if lp_aum<3
	replace lp_aum = 1 if lp_aum>=3 & !missing(lp_aum)
	label var lp_aum "Large Investor"
	
	**** relabeling ***
	label var lp_registered_cap_value "High Registered Capital"
	label var govlplink "Had Gov-LP"
	label var centrallink "Had Central Gov-LP"
	label var provinciallink "Had Provincial Gov-LP"
	label var locallink "Had Local Gov-LP"
	
	
******** gp choose lp regression *****
global mainvar lp_relation_gov lp_aum lp_registered_cap_value lp_industry lp_post_2010 lp_foreign_dummy lp_beijing_dummy lp_compliance lp_ideology lp_investment_stage 
global control1 lp_invest_restriction lp_top lp_team_connection lp_team_experience
global fe_model i.gp_fe

global speci1 $mainvar 
global speci2 $mainvar $control1
global speci3 $speci1 $fe_model	
global speci4 $speci2 $fe_model


gen gov_cri_1 = (gp_total_gov_share>=0 & !missing(gp_total_gov_share)) // many other gov definitions could be used here

*Partner Rating *
foreach var in q2 {
	if "`var'"=="q1" {
        	local c_note = "m"
        }
        else if "`var'" == "q2" {
        	local c_note = "i"
        }
        else {
        	local c_note = "a"
        }
        ************** gov-affiliated GP ******************
        qui sum `var' if locallink  == 1
        global mean_dp_all:dis %6.3f `r(mean)' 
        global sd_dp_all: dis %6.3f `r(sd)' 
		
		qui sum `var' if locallink  == 0 
        global mean_dp_full:dis %6.3f `r(mean)' 
        global sd_dp_full: dis %6.3f `r(sd)' 

        forval i=1(2)3 {
                eststo col`i'_all_`c_note': qui reg `var' ${speci`i'} if locallink ==1, robust
                        if `i'<=2 {
                                estadd local l_fe "No", replace
                        }
                        else {
                                estadd local l_fe "Yes", replace
                        }
                        qui tab gp_id if _est_col`i'_all_`c_note'
                        estadd local u_id `r(r)', replace
                        estadd local model_des "OLS"
                        estadd local mean $mean_dp_all
                        estadd local sd $sd_dp_all

				eststo col`i'_full_`c_note': qui reg `var' ${speci`i'} if locallink ==0, robust
                        if `i'<=2 {
                                estadd local l_fe "No", replace
                        }
                        else {
                                estadd local l_fe "Yes", replace
                        }
                        qui tab gp_id if _est_col`i'_full_`c_note'
                        estadd local u_id `r(r)', replace
                        estadd local model_des "OLS"
                        estadd local mean $mean_dp_full
                        estadd local sd $sd_dp_full
        }
}


**** two tables for different samples *******
esttab col1_all_i col1_full_i col3_all_i col3_full_i using "$appendixtable_dir/TableA33_regression.tex", label booktabs eqlabels(none) replace ///
	star(* 0.1 ** 0.05 *** 0.01) t(%6.2f) b(%8.3f)  ///
        stats(N u_id r2 l_fe model_des mean sd,labels("Observations" "Unique GPs" "R-Squared"  "GP FEs" "Model" "DV Mean" "DV SD") fmt(a3 a3 %8.3f a3 a3 %6.3f %6.3f)) ///
	mtitle("W/L_Gov" "W/out L_Gov" "W/L_Gov" "W/out L_Gov") title("GP Preferences for LPs: Heterogeneity by Local Gov-LP-linked GPs") ///
	drop(*gp_fe _cons) 

**** test coefficient ****
bysort gp_fe: center q1 q2 q3, prefix(cy_)
bysort gp_fe: center $speci1, prefix(cx_)
*** gov_affiliated GP vs non_gov_affiliated GP ***
*Cooperation Interest (Meeting Dummy) Partner Grading  Expected Interests  for different samples*
foreach var in q2 {
	if "`var'"=="q1" {
        	local c_note = "m"
        }
        else if "`var'" == "q2" {
        	local c_note = "i"
        }
        else {
        	local c_note = "a"
        }
	************** gov-affiliated GP ******************
        eststo col3_all_`c_note': qui reg `var' $speci1 if locallink ==1
        eststo col6_all_`c_note': qui reg cy_`var' cx_* if locallink ==1
       
        ****** non gov-affiliated GP *****
        eststo col3_all_n_`c_note': qui reg `var' $speci1 if locallink ==0
        eststo col6_all_n_`c_note': qui reg cy_`var' cx_* if locallink ==0

        ***** generate the estimator comparison for two groups for the same dep var ****
        
        ***** all sample ***
        eststo com1_all_`c_note': qui suest col3_all_`c_note' col3_all_n_`c_note', vce(robust)
        foreach var in $speci1 {
                qui test [col3_all_`c_note'_mean]`var'=[col3_all_n_`c_note'_mean]`var'
                estadd scalar `var' = r(p)
                
        }
        estadd local l_fe "No" 

        eststo com2_all_`c_note': qui suest col6_all_`c_note' col6_all_n_`c_note', vce(robust)
        foreach var in $speci1 {
                qui test [col6_all_`c_note'_mean]cx_`var'=[col6_all_n_`c_note'_mean]cx_`var'
                estadd scalar `var' = r(p)        
        }
        estadd local l_fe "Yes" 
        
        
}


esttab com1_all_i com2_all_i using "$appendixtable_dir/TableA33_SURtest.tex", label booktabs eqlabels(none) replace stats($speci1 l_fe, label("Government Ties" "Large Investor" "High Registered Capital" "Industry Information" "Young LP" "Headquarter In Foreign Country" "Headquarter In Beijing" "Corporate Governance" "Investment Philosophy" "Stage Focus" "GP FEs") fmt(%8.3f %8.3f %8.3f %8.3f %8.3f %8.3f %8.3f %8.3f %8.3f %8.3f %8.3f a3)) ///
        mtitle("P-Value" "P-Value") title("Difference in Coefficients (p-value) Gov VS Non-Gov (Full Sample)") drop(*)

eststo clear

**** to form the final table, use a simple Python code to transform the latex files （text_gene.py）***
/*==============================================================================
Table A34. Government Experience of Individual Respondents
===============================================================================*/
use "$survey_dir/1000respondent_list.dta", clear
keep if gp==1
duplicates drop gp_fullname,force

gen temp = 1
bys temp: count if gov_own==1 & gov_tie1==1
global mg11 = r(N)

bys temp: count if gov_own==0 & gov_tie1==1
global mg12 = r(N)

global mg13= $mg11+$mg12

bys temp: count if gov_own==1 & gov_tie1==0
global mg21 = r(N)

bys temp: count if gov_own==0 & gov_tie1==0
global mg22 = r(N)

global mg23= $mg21+$mg22

global mg31= $mg11+$mg21
global mg32= $mg12+$mg22
global mg33= $mg13+$mg23

local file "$appendixtable_dir/TableA34.tex"
                cap file close file2
                file open file2 using "`file'", write replace
                file write file2 "\begin{tabular}{lccc}  \hline " _n
                file write file2 "  &  Gov Owned&NonGov Owned&Total\\"
				file write file2 "\midrule"
                file write file2 "Gov Tied & $mg11 & $mg12 & $mg13 \\"             
                file write file2 "NonGov Tied & $mg21 & $mg22 & $mg23 \\"
                file write file2 "\midrule"
				file write file2 "Total & $mg31 & $mg32 & $mg33 \\"
				file write file2 "\midrule"
                file close file2 
drop temp
/*==============================================================================
Table A35. GP Preferences for LPs: Heterogeneity by Individual Respondents with Government Experience
===============================================================================*/

use "$survey_dir/GP_reg_individual_character_hetero.dta", clear

	drop if gp_id=="CAU"| gp_id=="FMZ" | gp_id=="OEJ"| gp_id=="QET"| gp_id=="QYN"| gp_id=="UTL"| gp_id=="UYM"| gp_id=="VUI"| gp_id=="XAJ"| gp_id=="XLJ"

	merge m:1 lp_profile_id using "$survey_dir/lp_profile_everyoption.dta", nogen keep(3)
	
	****** regrouping effort ****
	replace lp_ideology = 1 if stage_2 == 1
	replace lp_investment_stage = 0 if stage_2==1 | stage_5 == 1
	label var lp_investment_stage "Stage Focus"

	replace lp_aum = 0 if lp_aum<3
	replace lp_aum = 1 if lp_aum>=3 & !missing(lp_aum)
	label var lp_aum "Large Investor"
	
	**** relabeling ***
	label var lp_registered_cap_value "High Registered Capital"
	
	
******** gp choose lp regression *****
global mainvar lp_relation_gov lp_aum lp_registered_cap_value lp_industry lp_post_2010 lp_foreign_dummy lp_beijing_dummy lp_compliance lp_ideology lp_investment_stage 
global control1 lp_invest_restriction lp_top lp_team_connection lp_team_experience
global fe_model i.gp_fe

global speci1 $mainvar 
global speci2 $mainvar $control1
global speci3 $speci1 $fe_model	
global speci4 $speci2 $fe_model


gen gov_cri_1 = (gp_total_gov_share>=0 & !missing(gp_total_gov_share)) // many other gov definitions could be used here

*Partner Rating *
foreach var in q2 {
	if "`var'"=="q1" {
        	local c_note = "m"
        }
        else if "`var'" == "q2" {
        	local c_note = "i"
        }
        else {
        	local c_note = "a"
        }
        ************** gov-affiliated GP ******************
        qui sum `var' if gov_tie1 == 1
        global mean_dp_all:dis %6.3f `r(mean)' 
        global sd_dp_all: dis %6.3f `r(sd)' 
		
		qui sum `var' if gov_tie1== 0 
        global mean_dp_full:dis %6.3f `r(mean)' 
        global sd_dp_full: dis %6.3f `r(sd)' 

        forval i=1(2)3 {
                eststo col`i'_all_`c_note': qui reg `var' ${speci`i'} if gov_tie1==1, robust
                        if `i'<=2 {
                                estadd local l_fe "No", replace
                        }
                        else {
                                estadd local l_fe "Yes", replace
                        }
                        qui tab gp_id if _est_col`i'_all_`c_note'
                        estadd local u_id `r(r)', replace
                        estadd local model_des "OLS"
                        estadd local mean $mean_dp_all
                        estadd local sd $sd_dp_all

				eststo col`i'_full_`c_note': qui reg `var' ${speci`i'} if gov_tie1==0, robust
                        if `i'<=2 {
                                estadd local l_fe "No", replace
                        }
                        else {
                                estadd local l_fe "Yes", replace
                        }
                        qui tab gp_id if _est_col`i'_full_`c_note'
                        estadd local u_id `r(r)', replace
                        estadd local model_des "OLS"
                        estadd local mean $mean_dp_full
                        estadd local sd $sd_dp_full
        }
}

**** two tables for different samples *******
esttab col1_all_i col1_full_i col3_all_i col3_full_i using "$appendixtable_dir/TableA35_regression.tex", label booktabs eqlabels(none) replace ///
	star(* 0.1 ** 0.05 *** 0.01) t(%6.2f) b(%8.3f)  ///
        stats(N u_id r2 l_fe model_des mean sd,labels("Observations" "Unique GPs" "R-Squared"  "GP FEs" "Model" "DV Mean" "DV SD") fmt(a3 a3 %8.3f a3 a3 %6.3f %6.3f)) ///
	mtitle("GovTied" "Non-GovTied" "GovTied" "Non-GovTied") title("GP Preferences for LPs: Heterogeneity by Individual Respondents with Government Experience") ///
	drop(*gp_fe _cons) 

**** test coefficient ****
bysort gp_fe: center q1 q2 q3, prefix(cy_)
bysort gp_fe: center $speci1, prefix(cx_)
*** gov_affiliated GP vs non_gov_affiliated GP ***
*Cooperation Interest (Meeting Dummy) Partner Grading  Expected Interests  for different samples*
foreach var in q2 {
	if "`var'"=="q1" {
        	local c_note = "m"
        }
        else if "`var'" == "q2" {
        	local c_note = "i"
        }
        else {
        	local c_note = "a"
        }
	************** gov-affiliated GP ******************
        eststo col3_all_`c_note': qui reg `var' $speci1 if gov_tie1==1
        eststo col6_all_`c_note': qui reg cy_`var' cx_* if gov_tie1==1
       
        ****** non gov-affiliated GP *****
        eststo col3_all_n_`c_note': qui reg `var' $speci1 if gov_tie1==0
        eststo col6_all_n_`c_note': qui reg cy_`var' cx_* if gov_tie1==0

        ***** generate the estimator comparison for two groups for the same dep var ****
        
        ***** all sample ***
        eststo com1_all_`c_note': qui suest col3_all_`c_note' col3_all_n_`c_note', vce(robust)
        foreach var in $speci1 {
                qui test [col3_all_`c_note'_mean]`var'=[col3_all_n_`c_note'_mean]`var'
                estadd scalar `var' = r(p)
                
        }
        estadd local l_fe "No" 

        eststo com2_all_`c_note': qui suest col6_all_`c_note' col6_all_n_`c_note', vce(robust)
        foreach var in $speci1 {
                qui test [col6_all_`c_note'_mean]cx_`var'=[col6_all_n_`c_note'_mean]cx_`var'
                estadd scalar `var' = r(p)        
        }
        estadd local l_fe "Yes" 
        
        
}

esttab com1_all_i com2_all_i using "$appendixtable_dir/TableA35_SURtest.tex", label booktabs eqlabels(none) replace stats($speci1 l_fe, label("Government Ties" "Large Investor" "High Registered Capital" "Industry Information" "Young LP" "Headquarter In Foreign Country" "Headquarter In Beijing" "Corporate Governance" "Investment Philosophy" "Stage Focus" "GP FEs") fmt(%8.3f %8.3f %8.3f %8.3f %8.3f %8.3f %8.3f %8.3f %8.3f %8.3f %8.3f a3)) ///
        mtitle("P-Value" "P-Value") title("Difference in Coefficients (p-value) Gov VS Non-Gov (Full Sample)") drop(*)

eststo clear

**** to form the final table, use a simple Python code to transform the latex files （text_gene.py）***

/*==============================================================================
Table A36. GP Preferences for LPs: Heterogeneity by Government-Owned GPs，Controlling for Individual Respondents having Government Experience
===============================================================================*/

use "$survey_dir/GP_reg_individual_character_hetero.dta", clear

	drop if gp_id=="CAU"| gp_id=="FMZ" | gp_id=="OEJ"| gp_id=="QET"| gp_id=="QYN"| gp_id=="UTL"| gp_id=="UYM"| gp_id=="VUI"| gp_id=="XAJ"| gp_id=="XLJ"

	merge m:1 lp_profile_id using "$survey_dir/lp_profile_everyoption.dta", nogen keep(3)
	
	****** regrouping effort ****
	replace lp_ideology = 1 if stage_2 == 1
	replace lp_investment_stage = 0 if stage_2==1 | stage_5 == 1
	label var lp_investment_stage "Stage Focus"

	replace lp_aum = 0 if lp_aum<3
	replace lp_aum = 1 if lp_aum>=3 & !missing(lp_aum)
	label var lp_aum "Large Investor"
	
	**** relabeling ***
	label var lp_registered_cap_value "High Registered Capital"
	
	
******** gp choose lp regression *****
global mainvar lp_relation_gov lp_aum lp_registered_cap_value lp_industry lp_post_2010 lp_foreign_dummy lp_beijing_dummy lp_compliance lp_ideology lp_investment_stage gov_tie1
global control1 lp_invest_restriction lp_top lp_team_connection lp_team_experience
global fe_model i.gp_fe

global speci1 $mainvar 
global speci2 $mainvar $control1
global speci3 $speci1 $fe_model	
global speci4 $speci2 $fe_model


gen gov_cri_1 = (gp_total_gov_share>=0 & !missing(gp_total_gov_share)) // many other gov definitions could be used here

*Partner Rating *
foreach var in q2 {
	if "`var'"=="q1" {
        	local c_note = "m"
        }
        else if "`var'" == "q2" {
        	local c_note = "i"
        }
        else {
        	local c_note = "a"
        }
        ************** gov-affiliated GP ******************
        qui sum `var' if gov_cri_1 == 1
        global mean_dp_all:dis %6.3f `r(mean)' 
        global sd_dp_all: dis %6.3f `r(sd)' 
		
		qui sum `var' if gov_cri_1 == 0 
        global mean_dp_full:dis %6.3f `r(mean)' 
        global sd_dp_full: dis %6.3f `r(sd)' 

        forval i=1(2)3 {
                eststo col`i'_all_`c_note': qui reg `var' ${speci`i'} if gov_cri_1==1, robust
                        if `i'<=2 {
                                estadd local l_fe "No", replace
                        }
                        else {
                                estadd local l_fe "Yes", replace
                        }
                        qui tab gp_id if _est_col`i'_all_`c_note'
                        estadd local u_id `r(r)', replace
                        estadd local model_des "OLS"
                        estadd local mean $mean_dp_all
                        estadd local sd $sd_dp_all

				eststo col`i'_full_`c_note': qui reg `var' ${speci`i'} if gov_cri_1==0, robust
                        if `i'<=2 {
                                estadd local l_fe "No", replace
                        }
                        else {
                                estadd local l_fe "Yes", replace
                        }
                        qui tab gp_id if _est_col`i'_full_`c_note'
                        estadd local u_id `r(r)', replace
                        estadd local model_des "OLS"
                        estadd local mean $mean_dp_full
                        estadd local sd $sd_dp_full
        }
}

**** two tables for different samples *******
esttab col1_all_i col1_full_i col3_all_i col3_full_i using "$appendixtable_dir/TableA36_regression.tex", label booktabs eqlabels(none) replace ///
	star(* 0.1 ** 0.05 *** 0.01) t(%6.2f) b(%8.3f)  ///
        stats(N u_id r2 l_fe model_des mean sd,labels("Observations" "Unique GPs" "R-Squared"  "GP FEs" "Model" "DV Mean" "DV SD") fmt(a3 a3 %8.3f a3 a3 %6.3f %6.3f)) ///
	mtitle("Gov" "Non-Gov" "Gov" "Non-Gov") title("GP Preferences for LPs: Heterogeneity by Government-Owned GPs，Controlling for Individual Respondents having Government Experience") ///
	drop(*gp_fe _cons) 

**** test coefficient ****
bysort gp_fe: center q1 q2 q3, prefix(cy_)
bysort gp_fe: center $speci1, prefix(cx_)
*** gov_affiliated GP vs non_gov_affiliated GP ***
*Cooperation Interest (Meeting Dummy) Partner Grading  Expected Interests  for different samples*
foreach var in q2 {
	if "`var'"=="q1" {
        	local c_note = "m"
        }
        else if "`var'" == "q2" {
        	local c_note = "i"
        }
        else {
        	local c_note = "a"
        }
	************** gov-affiliated GP ******************
        eststo col3_all_`c_note': qui reg `var' $speci1 if gov_cri_1==1
        eststo col6_all_`c_note': qui reg cy_`var' cx_* if gov_cri_1==1
       
        ****** non gov-affiliated GP *****
        eststo col3_all_n_`c_note': qui reg `var' $speci1 if gov_cri_1==0
        eststo col6_all_n_`c_note': qui reg cy_`var' cx_* if gov_cri_1==0

        ***** generate the estimator comparison for two groups for the same dep var ****
        
        ***** all sample ***
        eststo com1_all_`c_note': qui suest col3_all_`c_note' col3_all_n_`c_note', vce(robust)
        foreach var in $speci1 {
                qui test [col3_all_`c_note'_mean]`var'=[col3_all_n_`c_note'_mean]`var'
                estadd scalar `var' = r(p)
                
        }
        estadd local l_fe "No" 

        eststo com2_all_`c_note': qui suest col6_all_`c_note' col6_all_n_`c_note', vce(robust)
        foreach var in $speci1 {
                qui test [col6_all_`c_note'_mean]cx_`var'=[col6_all_n_`c_note'_mean]cx_`var'
                estadd scalar `var' = r(p)        
        }
        estadd local l_fe "Yes" 
        
        
}

esttab com1_all_i com2_all_i using "$appendixtable_dir/TableA36_SURtest.tex", label booktabs eqlabels(none) replace stats($speci1 l_fe, label("Government Ties" "Large Investor" "High Registered Capital" "Industry Information" "Young LP" "Headquarter In Foreign Country" "Headquarter In Beijing" "Corporate Governance" "Investment Philosophy" "Stage Focus" "GP FEs") fmt(%8.3f %8.3f %8.3f %8.3f %8.3f %8.3f %8.3f %8.3f %8.3f %8.3f %8.3f a3)) ///
        mtitle("P-Value" "P-Value") title("Difference in Coefficients (p-value) Gov VS Non-Gov (Full Sample)") drop(*)

eststo clear

**** to form the final table, use a simple Python code to transform the latex files （text_gene.py）***

/*==============================================================================
Table A37. 2021 Qualitative Survey: Selection of Respondents
===============================================================================*/
* 
import excel using "$survey2021_dir/2021new_survey_second_round.xlsx", firstrow case(lower) clear
	keep gp_id
	tempfile r2
	save `r2', replace
	
import excel using "$survey2021_dir/2021new_survey_first_round.xlsx", firstrow case(lower) clear
	keep gp_id
	append using `r2'
	gen resp=1
	tempfile resp
	save `resp', replace

use "$survey_dir/gp_survey_data_regress.dta", clear
	keep gp_id gp_fullname
	duplicates drop
	merge 1:1 gp_id using `resp', nogen keep(3)
	drop gp_id
	tempfile resp
	save `resp', replace
	
use "$zero2ipo_dir/ActiveOwnershipGP_2015-19_SummaryStats.dta", clear
	keep if gp_respondent == 1
	merge 1:1 gp_fullname using `resp', nogen
	replace resp = 0 if missing(resp)
	gen gov = (!missing(gp_total_gov_share) & gp_total_gov_share>=0)
	
	encode hq_province_group, gen(hq_province_group_fe)
	
	label var gov "Gov"
	label var AUMrmb "AUM"
	label var gp_irr "IRR"
	label var Num_mgt_fund "Num of Fund Management"
	label var Number_investment "Num of Investment"
	label var Number_exits "Num of Exit"

winsor2 AUMrmb , cuts(0 95) replace
winsor2 gp_irr , cuts(0 95) replace

gen govresp = gov if resp==1
gen AUMrmbresp = AUMrmb if resp==1
gen gp_irrresp = gp_irr if resp==1
gen Num_mgt_fundresp = Num_mgt_fund if resp==1
gen Number_investmentresp = Number_investment if resp==1
gen Number_exitsresp = Number_exits if resp==1

drop if hq_province_group=="Foreign Countries"

* p-values of ttests
ttest gov = govresp, unpaired
local sr14=`r(p)'
ttest AUMrmb = AUMrmbresp, unpaired
local sr24=`r(p)'
ttest gp_irr = gp_irrresp, unpaired
local sr34=`r(p)'
ttest Num_mgt_fund = Num_mgt_fundresp, unpaired
local sr44=`r(p)'
ttest Number_investment = Number_investmentresp, unpaired
local sr54=`r(p)'
ttest Number_exits = Number_exitsresp, unpaired
local sr64=`r(p)'

* values of variables
sum gov if resp==1
local sr12=100*`r(mean)'
sum gov
local sr13=100*`r(mean)'

sum  AUMrmb if resp==1
local sr22=`r(mean)'/7
sum AUMrmb
local sr23=`r(mean)'/7

egen median_sr32=median(gp_irrresp) 
scalar med_sr32 = median_sr32
local sr32=med_sr32

egen median_sr33=median(gp_irr) 
scalar med_sr33 = median_sr33
local sr33=med_sr33

sum Num_mgt_fund if resp==1
local sr42=`r(mean)'
sum Num_mgt_fund 
local sr43=`r(mean)'
sum Number_investment if resp==1
local sr52=`r(mean)'
sum Number_investment
local sr53=`r(mean)'
sum Number_exits if resp==1
local sr62=`r(mean)'
sum Number_exits
local sr63=`r(mean)'

local file "$appendixtable_dir/TableA37.tex"
                cap file close file3
                file open file3 using "`file'", write replace
                file write file3 "\begin{tabular}{lccc}  \hline " _n
                file write file3 "  & New Syrvey Respondents (N=361)&All Respondents(N=688)&P-value\\"
				file write file3 "\midrule"
                file write file3 "Share Government-Owned (%) & `sr12' & `sr13' & `sr14' \\"             
                file write file3 "AUM ($ millons)& `sr22' & `sr23' & `sr24' \\"
                file write file3 "IRR (% median)& `sr32' & `sr33' & `sr34' \\"
				file write file3 "Funds & `sr42' & `sr43' & `sr44' \\"
				file write file3 "Investemnts & `sr52' & `sr53' & `sr54' \\"
				file write file3 "Exits & `sr62' & `sr63' & `sr64' \\"
				file write file3 "\midrule"
                file close file3 
drop median_sr32
drop median_sr33
/*========================================================================
Table A38. Text Analysis of Open-Ended Qusetions Regarding Government Investors
========================================================================*/
import excel "$survey2021_dir/qualitativesurvey_matchwithoptions.xlsx", sheet("Sheet1") firstrow clear
gen temp1=1
bys temp:count if match1_ra1==1
global ra11: dis %8.2f r(N)/1.27

bys temp:count if match1_ra1==2
global ra12: dis %8.2f r(N)/1.27

bys temp:count if match1_ra1==3
global ra13: dis %8.2f r(N)/1.27

bys temp:count if match1_ra1==4
global ra14: dis %8.2f r(N)/1.27

bys temp:count if match1_ra1==5
global ra15: dis %8.2f r(N)/1.27

bys temp:count if others_ra1==1
global ra16: dis %8.2f r(N)/1.27

bys temp:count if match1_ra2==1
global ra21: dis %8.2f r(N)/1.27

bys temp:count if match1_ra2==2
global ra22: dis %8.2f r(N)/1.27

bys temp:count if match1_ra2==3
global ra23: dis %8.2f r(N)/1.27

bys temp:count if match1_ra2==4
global ra24: dis %8.2f r(N)/1.27

bys temp:count if match1_ra2==5
global ra25: dis %8.2f r(N)/1.27

bys temp:count if others_ra2==1
global ra26: dis %8.2f r(N)/1.27

local file "$appendixtable_dir/TableA38.tex"
                cap file close file3
                file open file3 using "`file'", write replace
                file write file3 "\begin{tabular}{lcc}  \hline " _n
                file write file3 " Mechanism & Research Assistant 1& Research Assistant 2\\"
				file write file3"\midrule\\"
                file write file3 "Investment Interference & $ra11 \% & $ra21 \% \\"             
                file write file3 "No Rsik Tolerance & $ra12 \% & $ra22 \% \\"
				file write file3 "Short Investment Horizon & $ra13 \% & $ra23 \%  \\"
                file write file3 "Lack of Professional Team & $ra14 \% & $ra24 \% \\"
				file write file3 "Exposure to Policy Uncertainty & $ra15 \% & $ra25 \% \\"
				file write file3  "Other & $ra16 \% & $ra26 \% \\"
				file write file3"\midrule\\"
				file write file3 "Total & 100\% & 100\% \\"
				file write file3"\midrule"
                file close file3
drop temp1
/*========================================================================
Table A39. Experimental Dislike for Government LPs and Stated Mechanisms
    see R code in the folder
========================================================================*/


/*========================================================================
Table A40. Summary Statistics with Gov defined as gov share >= 20% 
	see R code in the folder
========================================================================*/
/*========================================================================
Table A41. Government-Owned GPs Perform Worse (Gov ≥ 20%)
	controlling AUM (winsorized)
	using winsorized IRR
	using min-max std CR2
========================================================================*/
use "$zero2ipo_dir/GP_performance_details.dta", clear
	keep GP_fullname gp* assort_sample
	ren *, lower
	tempfile performance
	save `performance', replace

use "$zero2ipo_dir/ActiveOwnershipGP_2015-19_SummaryStats.dta", clear
	keep gp_fullname hq_province_group
	tempfile hqnew
	save `hqnew', replace
	
***** gp regression ****
use "$zero2ipo_dir/gp_ownershipsample_info.dta", clear
		**** keep if assort_sample == 1
		merge 1:1 gp_fullname using `hqnew', nogen keep(3)
		
        **** gen hq fe for regressions (missing gp_hq_province_group are not included) ***
        encode hq_province_group, gen(gphq)
		label var gphq "GP HQ fixed effects"
		
        **** gov GP (missing gp_total_gov_share means no gov shares, 0 means gov shares but percentages are missing) ****
        gen gpgov_relate = (gp_total_gov_share >=20 & !missing(gp_total_gov_share))  	
        label var gpgov_relate "Gov GPs"
		drop gp_rank_comprehensivereturn gp_irr 
		merge 1:1 gp_fullname using `performance', nogen keep(3)
		
**** link sample ****
*keep if assort_sample == 1
       **** gov GP (missing gp_total_gov_share means no gov shares, 0 means gov shares but percentages are missing) ****
        replace gpgov_relate = (gp_total_gov_share >=20 & !missing(gp_total_gov_share ))  	
       
local model_num = 0
label var gp_rank_fundraisingusd "Fund Raising Amount"
egen min_gp_comprehensive_return = min(gp_comprehensive_return)
egen max_gp_comprehensive_return = max(gp_comprehensive_return)
gen gp_comprehensive_return_std = (gp_comprehensive_return - min_gp_comprehensive_return)/(max_gp_comprehensive_return - min_gp_comprehensive_return)

winsor gp_irr, gen(W_gp_irr) p(0.05) highonly
winsor gp_rank_aumusd, gen(W_gp_rank_aumusd) p(0.05) highonly

label var W_gp_rank_aumusd "AUM"

foreach var in gp_comprehensive_return_std  W_gp_irr  {
        local model_num = `model_num' + 1
        eststo col1_`model_num': qui reg `var' gpgov_relate, robust
                estadd local hq_fe "No"
               
        eststo col2_`model_num': qui reg `var' gpgov_relate i.gphq, robust
                estadd local hq_fe "Yes"
				
		eststo col3_`model_num': qui reg `var' gpgov_relate W_gp_rank_aumusd, robust
                estadd local hq_fe "No"
		
		eststo col4_`model_num': qui reg `var' gpgov_relate W_gp_rank_aumusd i.gphq, robust
				estadd local hq_fe "Yes"
}
	
esttab col1_1 col2_1 col3_1 col4_1 col1_2 col2_2 col3_2 col4_2 using "$appendixtable_dir/TableA41.tex", label booktabs eqlabels(none) replace ///
	star(* 0.1 ** 0.05 *** 0.01) t(%6.2f) b(%8.3f)  ///
        stats(N r2 hq_fe ,labels("Observations" "R-Squared"  "HQ FEs" ) fmt(a3 %8.3f a3)) ///
	mtitle("CR" "CR" "CR" "CR" "IRR" "IRR" "IRR" "IRR") title(" Government-Owned GPs Perform Worse (Government-owned if Ownership ≥ 20%)") ///
	drop(*gphq _cons) 
	
eststo clear	

/*========================================================================
Table A42. Assortative Matching Between Government-Owned GPs and LPs (Gov ≥ 20%)
=======================================================================*/
use "$zero2ipo_dir/GP_performance_details.dta", clear
ren *, lower
*** use 10-90 winsorized irr *****
replace gp_irr = gp_irr_1090 
keep gp_fullname gp_exit_invest gp_irr gp_comprehensive_return // could add any new measures we want to use here
*merge 1:1 gp_fullname using `cr2win', nogen keep(3)
	tempfile cr2win
	save `cr2win', replace

**** could get median here if want to impute later, same for lp performance measures ***

*tempfile gp_perform
*save `gp_perform', replace

***** link perform data to assortative matching sample ****
use "$zero2ipo_dir/assortativematching_newactivesample", clear
		***** note that the data set includes link_year link_amount link_total_lp for each link between GP-LP pairs ****
        ***** a GP-LP pair may appear in the data sets more than once if they have links in different fundraising events ****
        duplicates drop // unique GP-LP pairs
		
		merge m:1 gp_fullname using `cr2win', nogen keep(3)
		*merge m:1 gp_fullname using `gp_perform', nogen
		egen min_gp_comprehensive_return = min(gp_comprehensive_return)
		egen max_gp_comprehensive_return = max(gp_comprehensive_return)
		gen gp_comprehensive_return_std = (gp_comprehensive_return - min_gp_comprehensive_return)/(max_gp_comprehensive_return - min_gp_comprehensive_return)
		
		qui sum gp_exit_invest, de
		global gp_exit_invest_med = `r(p50)'
		qui sum gp_comprehensive_return_std, de
		global gp_cr_med = `r(p50)'
		qui sum gp_irr, de
		global gp_irr_med = `r(p50)'
		
****** the next main step: gen quality/gov measure for GP & gov measure for LP *********
****** generate gov LP, gov GP and high quality GP ****
        **** gov LP (missing lp_total_gov_share means no gov shares, 0 means gov shares but percentages are missing) ****
        **** lptype_en to include GGF and government bureau as gov LP ****
        gen lpgov_relate = ((lp_total_gov_share>=20& !missing(lp_total_gov_share)) | inlist(lptype_en,"Government Guide Fund","Government Bureau "))
        label var lpgov_relate "Gov-related LPs"
        **** gov GP (missing gp_total_gov_share means no gov shares, 0 means gov shares but percentages are missing) ****
        **** other gov variables: gpgov_relate_by_lp_2016 and gpgov_relate_by_lp_2018 (if use these two defs, may restrict links to 2016-2019 and 2018-2019 respectively) ****
        gen gpgov_relate = (gp_total_gov_share>=20 & !missing(gp_total_gov_share))
        label var gpgov_relate "Gov-related GPs"
        

        **** quality measures: gp_topranked gp_comprehensive_return gp_exit_invest_1 gp_irr ******
        gen gpabovemedian = (gp_comprehensive_return_std>=$gp_cr_med & !missing(gp_comprehensive_return_std))
		*** also, if top ranked, take it as high quality ***
		replace gpabovemedian = (gp_topranked==1) if gpabovemedian == 0 
		
        label var gpabovemedian "High Quality GPs"
        
		***** Table : Gov VS Gov *******
		gen type_gov = 1 if gpgov_relate==1 & lpgov_relate==1 // Gov GP + Gov LP
        replace type_gov = 2 if gpgov_relate==0 & lpgov_relate==1 // Non-Gov GP + Gov LP
        replace type_gov = 3 if gpgov_relate==1 & lpgov_relate==0 // Gov GP + Non-Gov LP
        replace type_gov = 4 if gpgov_relate==0 & lpgov_relate==0 // Non-Gov GP + Non-Gov LP
        label var type_gov "Link Type based on Gov GP VS Gov LP"
        qui tab type_gov, matcell(gov_prob)

        **** distribution of every link type ***  
        global gov_both = gov_prob[1,1]
        global gov_lp_nongov_gp = gov_prob[2,1]
        global gov_gp_nongov_lp = gov_prob[3,1]
        global gov_neither = gov_prob[4,1]

        **** distribution of GP/LP types among unique GP/LP with links in the ownership sample ****
        **** used as probability in the denominator when calculating the likelihood ratio ****   
        preserve
                keep gp_fullname gpgov_relate
                duplicates drop

                qui tab gpgov_relate, matcell(gov)
                global gp_gov = gov[2,1]/_N
                global gp_nogov = gov[1,1]/_N
        restore
        preserve
                keep lp_fullname lpgov_relate
                duplicates drop
                qui tab lpgov_relate, matcell(gov)
                global lp_gov = gov[2,1]/_N
                global lp_nogov = gov[1,1]/_N
        restore  
        global t_link = _N
        **** generate matrix number = (observed probability of type ij link)/ ((probability of type i GP)*(probability of type j LP)) ****
        global g11 = $gov_both / ($gp_gov * $lp_gov * $t_link )
        global g12 = $gov_lp_nongov_gp /($gp_nogov * $lp_gov * $t_link )
        global g21 = $gov_gp_nongov_lp /($gp_gov * $lp_nogov * $t_link )
        global g22 = $gov_neither /($gp_nogov * $lp_nogov * $t_link )
        global g_index = ($gov_both + $gov_neither )/ ($gp_gov * $lp_gov * $t_link + $gp_nogov *$lp_nogov * $t_link )

        ***************** construct the matrix output in latex *******
        *** col ratio and row ratio ***
        global g13: dis %6.3f $g11 / $g21
        global g23: dis %6.3f $g12 / $g22
        global g31: dis %6.3f $g11 / $g12
        global g32: dis %6.3f $g21 / $g22
        *** distribution of type ij link ***
        global p1: dis %8.2f $gov_both *100/$t_link
        global p2: dis %8.2f $gov_gp_nongov_lp *100/$t_link
        global p3: dis %8.2f $gov_lp_nongov_gp *100/$t_link
        global p4: dis %8.2f $gov_neither *100/$t_link
        foreach var in g11 g12 g21 g22 g_index {
                global `var': dis %6.3f ${`var'}
        }
        
        
        ********************* p-value for Col Ratio and Row Ratio ----- Binomial Test *******
        qui bitesti ($gov_both+$gov_gp_nongov_lp) $gov_both   $lp_gov
        global p_colrat1: dis %6.3f `r(p)'
        qui bitesti ($gov_lp_nongov_gp+$gov_neither) $gov_lp_nongov_gp $lp_gov
        global p_colrat2: dis %6.3f `r(p)'
        qui bitesti ($gov_both+$gov_lp_nongov_gp) $gov_both $gp_gov
        global p_rowrat1: dis %6.3f `r(p)'
        qui bitesti ($gov_gp_nongov_lp+$gov_neither) $gov_gp_nongov_lp $gp_gov
        global p_rowrat2: dis %6.3f `r(p)'        
        
        **** chi2 test for homogeneity *****
		/*==================================
		Table : Assortative Matching Between Government-Owned GPs and LPs
		===================================*/
        qui tabulate gpgov_relate lpgov_relate, chi2
        global p_chi_gg: dis %6.3f `r(p)'
                
                local file "$appendixtable_dir/TableA42.tex"
                cap file close file1 
                file open file1 using "`file'", write replace
                file write file1 "\begin{tabular}{lccc}  \hline\hline " _n
                file write file1 "  &  Gov LP&Non-Gov LP& ColRatio\\"
                file write file1 "Gov GP & $g11 & $g21 & $g13 \\"
                file write file1 "& ($p1 \%) & ($p2 \%) & ($p_colrat1) \\"
                file write file1 "Non-Gov GP & $g12 & $g22 & $g23 \\"
                file write file1 "& ($p3 \%) & ($p4 \%) & ($p_colrat2)\\"
                file write file1 "RowRatio & $g31 & $g32 & \\"
                file write file1 " & ($p_rowrat1) & ($p_rowrat2) & \\"
                file write file1 "\midrule"
                file write file1 "\textbf{Assortative Index}& \multicolumn{3}{c}{$g_index }\\"
                file write file1 "Homogeneity Test(p-value) & \multicolumn{3}{c}{$p_chi_gg }\\"
                file write file1 "\hline\hline \end{tabular}" 
                file close file1 
/*========================================================================
Table A43. GP Preferences for LPs: Heterogeneity by Government-Owned GPs (Gov ≥ 20%)
========================================================================*/
use "$survey_dir/gp_survey_data_regress.dta", clear

	drop if gp_id=="CAU"| gp_id=="FMZ" | gp_id=="OEJ"| gp_id=="QET"| gp_id=="QYN"| gp_id=="UTL"| gp_id=="UYM"| gp_id=="VUI"| gp_id=="XAJ"| gp_id=="XLJ"

	merge m:1 lp_profile_id using "$survey_dir/lp_profile_everyoption.dta", nogen keep(3)
	
	****** regrouping effort ****
	replace lp_ideology = 1 if stage_2 == 1
	replace lp_investment_stage = 0 if stage_2==1 | stage_5 == 1
	label var lp_investment_stage "Stage Focus"
	
	replace lp_aum = 0 if lp_aum<3
	replace lp_aum = 1 if lp_aum>=3 & !missing(lp_aum)
	label var lp_aum "Large Investor"
	
	**** relabeling ***
	label var lp_registered_cap_value "High Registered Capital"
	
	
******** gp choose lp regression *****
global mainvar lp_relation_gov lp_aum lp_registered_cap_value lp_industry lp_post_2010 lp_foreign_dummy lp_beijing_dummy lp_compliance lp_ideology lp_investment_stage 
global control1 lp_invest_restriction lp_top lp_team_connection lp_team_experience
global fe_model i.gp_fe

global speci1 $mainvar 
global speci2 $mainvar $control1
global speci3 $speci1 $fe_model	
global speci4 $speci2 $fe_model


gen gov_cri_1 = (gp_total_gov_share>=20 & !missing(gp_total_gov_share)) // many other gov definitions could be used here

*Partner Rating *
foreach var in q2 {
	if "`var'"=="q1" {
        	local c_note = "m"
        }
        else if "`var'" == "q2" {
        	local c_note = "i"
        }
        else {
        	local c_note = "a"
        }
        ************** gov-affiliated GP ******************
        qui sum `var' if gov_cri_1 == 1
        global mean_dp_all:dis %6.3f `r(mean)' 
        global sd_dp_all: dis %6.3f `r(sd)' 
		
		qui sum `var' if gov_cri_1 == 0 
        global mean_dp_full:dis %6.3f `r(mean)' 
        global sd_dp_full: dis %6.3f `r(sd)' 

        forval i=1(2)3 {
                eststo col`i'_all_`c_note': qui reg `var' ${speci`i'} if gov_cri_1==1, robust
                        if `i'<=2 {
                                estadd local l_fe "No", replace
                        }
                        else {
                                estadd local l_fe "Yes", replace
                        }
                        qui tab gp_id if _est_col`i'_all_`c_note'
                        estadd local u_id `r(r)', replace
                        estadd local model_des "OLS"
                        estadd local mean $mean_dp_all
                        estadd local sd $sd_dp_all

				eststo col`i'_full_`c_note': qui reg `var' ${speci`i'} if gov_cri_1==0, robust
                        if `i'<=2 {
                                estadd local l_fe "No", replace
                        }
                        else {
                                estadd local l_fe "Yes", replace
                        }
                        `qui tab gp_id if _est_col`i'_full_`c_note''
                        estadd local u_id `r(r)', replace
                        estadd local model_des "OLS"
                        estadd local mean $mean_dp_full
                        estadd local sd $sd_dp_full
        }
}


**** two tables for different samples *******
esttab col1_all_i col1_full_i col3_all_i col3_full_i using "$appendixtable_dir/TableA43_regression.tex", label booktabs eqlabels(none) replace ///
	star(* 0.1 ** 0.05 *** 0.01) t(%6.2f) b(%8.3f)  ///
        stats(N u_id r2 l_fe model_des mean sd,labels("Observations" "Unique GPs" "R-Squared"  "GP FEs" "Model" "DV Mean" "DV SD") fmt(a3 a3 %8.3f a3 a3 %6.3f %6.3f)) ///
	mtitle("Gov" "Non-Gov" "Gov" "Non-Gov") title("GP Preferences for LPs: Heterogeneity by Government-Owned GPs (Government-owned if Ownership ≥ 20%)") ///
	drop(*gp_fe _cons) 

**** test coefficient ****
bysort gp_fe: center q1 q2 q3, prefix(cy_)
bysort gp_fe: center $speci1, prefix(cx_)
*** gov_affiliated GP vs non_gov_affiliated GP ***
*Cooperation Interest (Meeting Dummy) Partner Grading  Expected Interests  for different samples*
foreach var in q2 {
	if "`var'"=="q1" {
        	local c_note = "m"
        }
        else if "`var'" == "q2" {
        	local c_note = "i"
        }
        else {
        	local c_note = "a"
        }
	************** gov-affiliated GP ******************
        eststo col3_all_`c_note': qui reg `var' $speci1 if gov_cri_1==1
        eststo col6_all_`c_note': qui reg cy_`var' cx_* if gov_cri_1==1
       
        ****** non gov-affiliated GP *****
        eststo col3_all_n_`c_note': qui reg `var' $speci1 if gov_cri_1==0
        eststo col6_all_n_`c_note': qui reg cy_`var' cx_* if gov_cri_1==0

        ***** generate the estimator comparison for two groups for the same dep var ****
        
        ***** all sample ***
        eststo com1_all_`c_note': qui suest col3_all_`c_note' col3_all_n_`c_note', vce(robust)
        foreach var in $speci1 {
                qui test [col3_all_`c_note'_mean]`var'=[col3_all_n_`c_note'_mean]`var'
                estadd scalar `var' = r(p)
                
        }
        estadd local l_fe "No" 

        eststo com2_all_`c_note': qui suest col6_all_`c_note' col6_all_n_`c_note', vce(robust)
        foreach var in $speci1 {
                qui test [col6_all_`c_note'_mean]cx_`var'=[col6_all_n_`c_note'_mean]cx_`var'
                estadd scalar `var' = r(p)        
        }
        estadd local l_fe "Yes" 
        
        
}

esttab com1_all_i com2_all_i using "$appendixtable_dir/TableA43_SURtest.tex", label booktabs eqlabels(none) replace stats($speci1 l_fe, label("Government Ties" "Large Investor" "High Registered Capital" "Industry Information" "Young LP" "Headquarter In Foreign Country" "Headquarter In Beijing" "Corporate Governance" "Investment Philosophy" "Stage Focus" "GP FEs") fmt(%8.3f %8.3f %8.3f %8.3f %8.3f %8.3f %8.3f %8.3f %8.3f %8.3f %8.3f a3)) ///
        mtitle("P-Value" "P-Value") title("Difference in Coefficients (p-value) Gov VS Non-Gov (Full Sample)") drop(*)

eststo clear

**** to form the final table, use a simple Python code to transform the latex files （text_gene.py）***
	
/*========================================================================
Table A44. Policy Counterfactuals
no code
========================================================================*/
